1
0
Fork 0
mirror of synced 2024-07-02 13:01:09 +12:00

Not Contains Postgres filter

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

View file

@ -176,7 +176,7 @@ class InternalBuilder {
const columnName = fieldNames[1] const columnName = fieldNames[1]
// @ts-ignore // @ts-ignore
query = query[rawFnc]( query = query[rawFnc](
`"${tableName}"."${columnName}"::jsonb @> ${stringifyArray(value)}` `${not}"${tableName}"."${columnName}"::jsonb @> ${stringifyArray(value)}`
) )
}) })
} else if (this.client === SqlClients.MY_SQL) { } 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({ const query = new Sql(SqlClients.POSTGRES, 10)._query(generateReadJson({
filters: { filters: {
notContains: { notContains: {
@ -326,7 +326,7 @@ describe("SQL query builder", () => {
})) }))
expect(query).toEqual({ expect(query).toEqual({
bindings: [10], 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}\"`
}) })
}) })
}) })