Not Contains Postgres filter
This commit is contained in:
parent
ce9a6a7141
commit
69135d34a7
|
@ -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) {
|
||||||
|
|
|
@ -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}\"`
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue