use oracle coalesce
This commit is contained in:
parent
8fbb978cca
commit
d50c937c68
|
@ -436,9 +436,10 @@ class InternalBuilder {
|
||||||
[value]
|
[value]
|
||||||
)
|
)
|
||||||
} else if (this.client === SqlClient.ORACLE) {
|
} else if (this.client === SqlClient.ORACLE) {
|
||||||
query = query[fnc](`${quotedIdentifier(this.client, key)} = ?`, [
|
query = query[fnc](
|
||||||
value,
|
`COALESCE(${quotedIdentifier(this.client, key)}, -1) = ?`,
|
||||||
])
|
[value]
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
query = query[fnc](
|
query = query[fnc](
|
||||||
`COALESCE(${quotedIdentifier(this.client, key)} = ?, FALSE)`,
|
`COALESCE(${quotedIdentifier(this.client, key)} = ?, FALSE)`,
|
||||||
|
@ -459,9 +460,10 @@ class InternalBuilder {
|
||||||
[value]
|
[value]
|
||||||
)
|
)
|
||||||
} else if (this.client === SqlClient.ORACLE) {
|
} else if (this.client === SqlClient.ORACLE) {
|
||||||
query = query[fnc](`${quotedIdentifier(this.client, key)} != ?`, [
|
query = query[fnc](
|
||||||
value,
|
`COALESCE(${quotedIdentifier(this.client, key)}, -1) != ?`,
|
||||||
])
|
[value]
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
query = query[fnc](
|
query = query[fnc](
|
||||||
`COALESCE(${quotedIdentifier(this.client, key)} != ?, TRUE)`,
|
`COALESCE(${quotedIdentifier(this.client, key)} != ?, TRUE)`,
|
||||||
|
|
|
@ -239,7 +239,7 @@ describe("SQL query builder", () => {
|
||||||
|
|
||||||
expect(query).toEqual({
|
expect(query).toEqual({
|
||||||
bindings: ["John", limit, 5000],
|
bindings: ["John", limit, 5000],
|
||||||
sql: `select * from (select * from (select * from (select * from "test" where "test"."name" = :1 order by "test"."id" asc) where rownum <= :2) "test" order by "test"."id" asc) where rownum <= :3`,
|
sql: `select * from (select * from (select * from (select * from "test" where COALESCE("test"."name", -1) = :1 order by "test"."id" asc) where rownum <= :2) "test" order by "test"."id" asc) where rownum <= :3`,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@ describe("SQL query builder", () => {
|
||||||
|
|
||||||
expect(query).toEqual({
|
expect(query).toEqual({
|
||||||
bindings: ["John", limit, 5000],
|
bindings: ["John", limit, 5000],
|
||||||
sql: `select * from (select * from (select * from (select * from "test" where "test"."name" != :1 order by "test"."id" asc) where rownum <= :2) "test" order by "test"."id" asc) where rownum <= :3`,
|
sql: `select * from (select * from (select * from (select * from "test" where COALESCE("test"."name", -1) != :1 order by "test"."id" asc) where rownum <= :2) "test" order by "test"."id" asc) where rownum <= :3`,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue