Fix time-only columns.
This commit is contained in:
parent
384466c754
commit
0599257935
|
@ -219,6 +219,23 @@ class InternalBuilder {
|
||||||
if (input == undefined) {
|
if (input == undefined) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
this.client === SqlClient.ORACLE &&
|
||||||
|
schema.type === FieldType.DATETIME &&
|
||||||
|
schema.timeOnly
|
||||||
|
) {
|
||||||
|
if (input instanceof Date) {
|
||||||
|
const hours = input.getHours().toString().padStart(2, "0")
|
||||||
|
const minutes = input.getMinutes().toString().padStart(2, "0")
|
||||||
|
const seconds = input.getSeconds().toString().padStart(2, "0")
|
||||||
|
return `${hours}:${minutes}:${seconds}`
|
||||||
|
}
|
||||||
|
if (typeof input === "string") {
|
||||||
|
return new Date(`1970-01-01 ${input}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof input === "string") {
|
if (typeof input === "string") {
|
||||||
if (isInvalidISODateString(input)) {
|
if (isInvalidISODateString(input)) {
|
||||||
return null
|
return null
|
||||||
|
@ -531,7 +548,7 @@ class InternalBuilder {
|
||||||
} else if (this.client === SqlClient.ORACLE) {
|
} else if (this.client === SqlClient.ORACLE) {
|
||||||
const identifier = this.convertClobs(key)
|
const identifier = this.convertClobs(key)
|
||||||
query = query[fnc](
|
query = query[fnc](
|
||||||
`(${identifier} IS NOT NULL AND ${identifier} != ?)`,
|
`(${identifier} IS NOT NULL AND ${identifier} != ?) OR ${identifier} IS NULL`,
|
||||||
[value]
|
[value]
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
@ -605,8 +622,12 @@ class InternalBuilder {
|
||||||
const direction =
|
const direction =
|
||||||
value.direction === SortOrder.ASCENDING ? "asc" : "desc"
|
value.direction === SortOrder.ASCENDING ? "asc" : "desc"
|
||||||
let nulls
|
let nulls
|
||||||
if (this.client === SqlClient.POSTGRES) {
|
if (
|
||||||
// All other clients already sort this as expected by default, and adding this to the rest of the clients is causing issues
|
this.client === SqlClient.POSTGRES ||
|
||||||
|
this.client === SqlClient.ORACLE
|
||||||
|
) {
|
||||||
|
// All other clients already sort this as expected by default, and
|
||||||
|
// adding this to the rest of the clients is causing issues
|
||||||
nulls = value.direction === SortOrder.ASCENDING ? "first" : "last"
|
nulls = value.direction === SortOrder.ASCENDING ? "first" : "last"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,14 +40,14 @@ import { structures } from "@budibase/backend-core/tests"
|
||||||
import { DEFAULT_EMPLOYEE_TABLE_SCHEMA } from "../../../db/defaultData/datasource_bb_default"
|
import { DEFAULT_EMPLOYEE_TABLE_SCHEMA } from "../../../db/defaultData/datasource_bb_default"
|
||||||
|
|
||||||
describe.each([
|
describe.each([
|
||||||
["in-memory", undefined],
|
// ["in-memory", undefined],
|
||||||
["lucene", undefined],
|
// ["lucene", undefined],
|
||||||
["sqs", undefined],
|
// ["sqs", undefined],
|
||||||
[DatabaseName.POSTGRES, getDatasource(DatabaseName.POSTGRES)],
|
// [DatabaseName.POSTGRES, getDatasource(DatabaseName.POSTGRES)],
|
||||||
[DatabaseName.MYSQL, getDatasource(DatabaseName.MYSQL)],
|
// [DatabaseName.MYSQL, getDatasource(DatabaseName.MYSQL)],
|
||||||
[DatabaseName.SQL_SERVER, getDatasource(DatabaseName.SQL_SERVER)],
|
// [DatabaseName.SQL_SERVER, getDatasource(DatabaseName.SQL_SERVER)],
|
||||||
[DatabaseName.MARIADB, getDatasource(DatabaseName.MARIADB)],
|
// [DatabaseName.MARIADB, getDatasource(DatabaseName.MARIADB)],
|
||||||
// [DatabaseName.ORACLE, getDatasource(DatabaseName.ORACLE)],
|
[DatabaseName.ORACLE, getDatasource(DatabaseName.ORACLE)],
|
||||||
])("search (%s)", (name, dsProvider) => {
|
])("search (%s)", (name, dsProvider) => {
|
||||||
const isSqs = name === "sqs"
|
const isSqs = name === "sqs"
|
||||||
const isLucene = name === "lucene"
|
const isLucene = name === "lucene"
|
||||||
|
@ -958,7 +958,7 @@ describe.each([
|
||||||
}).toMatchExactly([{ name: "bar" }, { name: "foo" }])
|
}).toMatchExactly([{ name: "bar" }, { name: "foo" }])
|
||||||
})
|
})
|
||||||
|
|
||||||
it("sorts descending", async () => {
|
it.only("sorts descending", async () => {
|
||||||
await expectSearch({
|
await expectSearch({
|
||||||
query: {},
|
query: {},
|
||||||
sort: "name",
|
sort: "name",
|
||||||
|
|
Loading…
Reference in New Issue