Can't save json via prepared statements

I am getting a strange entry in my db while trying to save json through a prepared statement This is my simplified prepared statement
const saveData = db.
insert(tableName)
.values({
jsonData: sql.placeholder("jsonData")
})
.prepare()
const saveData = db.
insert(tableName)
.values({
jsonData: sql.placeholder("jsonData")
})
.prepare()
This is how I am calling it
// Neither of these work
await saveData.execute({ jsonData: jsonData })
await saveData.execute({
jsonData: JSON.stringify(jsonData)
})
// Neither of these work
await saveData.execute({ jsonData: jsonData })
await saveData.execute({
jsonData: JSON.stringify(jsonData)
})
Finally this is what shows up in the json column in the db
{"name": "jsonData"}
{"name": "jsonData"}
What am I missing?
1 Reply
chronos
chronosOP12mo ago
Seems like a github issue is open for the same. Added this comment there too https://github.com/drizzle-team/drizzle-orm/issues/1117
GitHub
[BUG]: Placeholder does not work with Json for prepared statement ·...
What version of drizzle-orm are you using? ^0.28.2 What version of drizzle-kit are you using? ^0.19.12 Describe the Bug Creating a prepared statement and using placeholder for dynamic data that is ...
Want results from more Discord servers?
Add your server