Not Contains Postgres filter

This commit is contained in:
Mel O'Hagan 2022-07-27 11:49:45 +01:00
parent ce9a6a7141
commit 69135d34a7
2 changed files with 3 additions and 3 deletions

View File

@ -176,7 +176,7 @@ class InternalBuilder {
const columnName = fieldNames[1]
// @ts-ignore
query = query[rawFnc](
`"${tableName}"."${columnName}"::jsonb @> ${stringifyArray(value)}`
`${not}"${tableName}"."${columnName}"::jsonb @> ${stringifyArray(value)}`
)
})
} else if (this.client === SqlClients.MY_SQL) {

View File

@ -315,7 +315,7 @@ describe("SQL query builder", () => {
})
})
it("should use jsonb operator expression for PostgreSQL when filter is notContains", () => {
it("should use jsonb operator NOT expression for PostgreSQL when filter is notContains", () => {
const query = new Sql(SqlClients.POSTGRES, 10)._query(generateReadJson({
filters: {
notContains: {
@ -326,7 +326,7 @@ describe("SQL query builder", () => {
}))
expect(query).toEqual({
bindings: [10],
sql: `select * from (select * from \"${TABLE_NAME}\" where \"${TABLE_NAME}\".\"age\"::jsonb @> '[20]' and \"${TABLE_NAME}\".\"name\"::jsonb @> '["John"]' limit $1) as \"${TABLE_NAME}\"`
sql: `select * from (select * from \"${TABLE_NAME}\" where NOT \"${TABLE_NAME}\".\"age\"::jsonb @> '[20]' and NOT \"${TABLE_NAME}\".\"name\"::jsonb @> '["John"]' limit $1) as \"${TABLE_NAME}\"`
})
})
})