-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Postgres JSONB 'destroy' with 'where' object fails #5092
Copy link
Copy link
Closed
Labels
type: bugDEPRECATED: replace with the "bug" issue typeDEPRECATED: replace with the "bug" issue type
Description
I'm using sequelize 3.15.0, postgres dialect on Mac OS X (El Cap). I have a column with JSONB
type. When destroying by using where object, it throws an exception.
var Page = sequelize.define('Page', {
content: Sequelize.JSONB
})Page.create({ name: "Test", content: { title: "Title" } })
.then(() => {
Page.destroy({ where: { content: { title: "Title" } } })
.then(() => {
sequelize.close()
})
})It throws.
Unhandled rejection TypeError: val.replace is not a function
at Object.SqlString.escape (/tmp/myapp/node_modules/sequelize/lib/sql-string.js:56:15)
at Object.QueryGenerator.escape (/tmp/myapp/node_modules/sequelize/lib/dialects/abstract/query-generator.js:983:22)
...
When using netsted key content.title, it also throws an exception though a different one.
Page.destroy({ where: { 'content.title': "Title" } })Unhandled rejection SequelizeDatabaseError: column "content.title" does not exist
at Query.formatError (/tmp/myapp/node_modules/sequelize/lib/dialects/postgres/query.js:347:14)
at null.<anonymous> (/tmp/myapp/node_modules/sequelize/lib/dialects/postgres/query.js:81:19)
...
However, using that same 'where' object with findOne or findAll works perfectly as expected.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type: bugDEPRECATED: replace with the "bug" issue typeDEPRECATED: replace with the "bug" issue type