Create search cross product on whether we save/search with timestamp.
This commit is contained in:
parent
26c0861e68
commit
7ad5879c3e
|
@ -1684,109 +1684,148 @@ if (descriptions.length) {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe.only("datetime - date only", () => {
|
describe.only("datetime - date only", () => {
|
||||||
const JAN_1ST = "2020-01-01"
|
describe.each([true, false])(
|
||||||
const JAN_10TH = "2020-01-10"
|
"saved with timestamp: %s",
|
||||||
const JAN_30TH = "2020-01-30"
|
saveWithTimestamp => {
|
||||||
const UNEXISTING_DATE = "2020-01-03"
|
describe.each([true, false])(
|
||||||
const NULL_DATE__ID = `null_date__id`
|
"search with timestamp: %s",
|
||||||
|
searchWithTimestamp => {
|
||||||
|
const SAVE_SUFFIX = saveWithTimestamp
|
||||||
|
? "T00:00:00.000Z"
|
||||||
|
: ""
|
||||||
|
const SEARCH_SUFFIX = searchWithTimestamp
|
||||||
|
? "T00:00:00.000Z"
|
||||||
|
: ""
|
||||||
|
|
||||||
beforeAll(async () => {
|
const JAN_1ST = `2020-01-01`
|
||||||
tableOrViewId = await createTableOrView({
|
const JAN_10TH = `2020-01-10`
|
||||||
dateid: { name: "dateid", type: FieldType.STRING },
|
const JAN_30TH = `2020-01-30`
|
||||||
date: {
|
const UNEXISTING_DATE = `2020-01-03`
|
||||||
name: "date",
|
const NULL_DATE__ID = `null_date__id`
|
||||||
type: FieldType.DATETIME,
|
|
||||||
dateOnly: true,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
await createRows([
|
beforeAll(async () => {
|
||||||
{ dateid: NULL_DATE__ID, date: null },
|
tableOrViewId = await createTableOrView({
|
||||||
{ date: JAN_1ST },
|
dateid: { name: "dateid", type: FieldType.STRING },
|
||||||
{ date: `${JAN_10TH}T00:00:00.000Z` },
|
date: {
|
||||||
])
|
name: "date",
|
||||||
})
|
type: FieldType.DATETIME,
|
||||||
|
dateOnly: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
describe("equal", () => {
|
await createRows([
|
||||||
it("successfully finds a row", async () => {
|
{ dateid: NULL_DATE__ID, date: null },
|
||||||
await expectQuery({
|
{ date: `${JAN_1ST}${SAVE_SUFFIX}` },
|
||||||
equal: { date: JAN_1ST },
|
{ date: `${JAN_10TH}${SAVE_SUFFIX}` },
|
||||||
}).toContainExactly([{ date: JAN_1ST }])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
it("successfully finds an ISO8601 row", async () => {
|
describe("equal", () => {
|
||||||
await expectQuery({
|
it("successfully finds a row", async () => {
|
||||||
equal: { date: JAN_10TH },
|
await expectQuery({
|
||||||
}).toContainExactly([{ date: JAN_10TH }])
|
equal: { date: `${JAN_1ST}${SEARCH_SUFFIX}` },
|
||||||
})
|
}).toContainExactly([{ date: JAN_1ST }])
|
||||||
|
})
|
||||||
|
|
||||||
it("finds a row with ISO8601 timestamp", async () => {
|
it("successfully finds an ISO8601 row", async () => {
|
||||||
await expectQuery({
|
await expectQuery({
|
||||||
equal: { date: `${JAN_1ST}T00:00:00.000Z` },
|
equal: { date: `${JAN_10TH}${SEARCH_SUFFIX}` },
|
||||||
}).toContainExactly([{ date: JAN_1ST }])
|
}).toContainExactly([{ date: JAN_10TH }])
|
||||||
})
|
})
|
||||||
|
|
||||||
it("fails to find nonexistent row", async () => {
|
it("finds a row with ISO8601 timestamp", async () => {
|
||||||
await expectQuery({
|
await expectQuery({
|
||||||
equal: { date: UNEXISTING_DATE },
|
equal: { date: `${JAN_1ST}${SEARCH_SUFFIX}` },
|
||||||
}).toFindNothing()
|
}).toContainExactly([{ date: JAN_1ST }])
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
describe("notEqual", () => {
|
it("fails to find nonexistent row", async () => {
|
||||||
it("successfully finds a row", async () => {
|
await expectQuery({
|
||||||
await expectQuery({
|
equal: {
|
||||||
notEqual: { date: JAN_1ST },
|
date: `${UNEXISTING_DATE}${SEARCH_SUFFIX}`,
|
||||||
}).toContainExactly([
|
},
|
||||||
{ date: JAN_10TH },
|
}).toFindNothing()
|
||||||
{ dateid: NULL_DATE__ID },
|
})
|
||||||
])
|
})
|
||||||
})
|
|
||||||
|
|
||||||
it("fails to find nonexistent row", async () => {
|
describe("notEqual", () => {
|
||||||
await expectQuery({
|
it("successfully finds a row", async () => {
|
||||||
notEqual: { date: JAN_30TH },
|
await expectQuery({
|
||||||
}).toContainExactly([
|
notEqual: { date: `${JAN_1ST}${SEARCH_SUFFIX}` },
|
||||||
{ date: JAN_1ST },
|
}).toContainExactly([
|
||||||
{ date: JAN_10TH },
|
{ date: JAN_10TH },
|
||||||
{ dateid: NULL_DATE__ID },
|
{ dateid: NULL_DATE__ID },
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
describe("oneOf", () => {
|
it("fails to find nonexistent row", async () => {
|
||||||
it("successfully finds a row", async () => {
|
await expectQuery({
|
||||||
await expectQuery({
|
notEqual: { date: `${JAN_30TH}${SEARCH_SUFFIX}` },
|
||||||
oneOf: { date: [JAN_1ST] },
|
}).toContainExactly([
|
||||||
}).toContainExactly([{ date: JAN_1ST }])
|
{ date: JAN_1ST },
|
||||||
})
|
{ date: JAN_10TH },
|
||||||
|
{ dateid: NULL_DATE__ID },
|
||||||
|
])
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
it("fails to find nonexistent row", async () => {
|
describe("oneOf", () => {
|
||||||
await expectQuery({
|
it("successfully finds a row", async () => {
|
||||||
oneOf: { date: [UNEXISTING_DATE] },
|
await expectQuery({
|
||||||
}).toFindNothing()
|
oneOf: { date: [`${JAN_1ST}${SEARCH_SUFFIX}`] },
|
||||||
})
|
}).toContainExactly([{ date: JAN_1ST }])
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("range", () => {
|
it("fails to find nonexistent row", async () => {
|
||||||
it("successfully finds a row", async () => {
|
await expectQuery({
|
||||||
await expectQuery({
|
oneOf: {
|
||||||
range: { date: { low: JAN_1ST, high: JAN_1ST } },
|
date: [`${UNEXISTING_DATE}${SEARCH_SUFFIX}`],
|
||||||
}).toContainExactly([{ date: JAN_1ST }])
|
},
|
||||||
})
|
}).toFindNothing()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
it("successfully finds multiple rows", async () => {
|
describe("range", () => {
|
||||||
await expectQuery({
|
it("successfully finds a row", async () => {
|
||||||
range: { date: { low: JAN_1ST, high: JAN_10TH } },
|
await expectQuery({
|
||||||
}).toContainExactly([{ date: JAN_1ST }, { date: JAN_10TH }])
|
range: {
|
||||||
})
|
date: {
|
||||||
|
low: `${JAN_1ST}${SEARCH_SUFFIX}`,
|
||||||
|
high: `${JAN_1ST}${SEARCH_SUFFIX}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}).toContainExactly([{ date: JAN_1ST }])
|
||||||
|
})
|
||||||
|
|
||||||
it("successfully finds no rows", async () => {
|
it("successfully finds multiple rows", async () => {
|
||||||
await expectQuery({
|
await expectQuery({
|
||||||
range: { date: { low: JAN_30TH, high: JAN_30TH } },
|
range: {
|
||||||
}).toFindNothing()
|
date: {
|
||||||
})
|
low: `${JAN_1ST}${SEARCH_SUFFIX}`,
|
||||||
})
|
high: `${JAN_10TH}${SEARCH_SUFFIX}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}).toContainExactly([
|
||||||
|
{ date: JAN_1ST },
|
||||||
|
{ date: JAN_10TH },
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
|
it("successfully finds no rows", async () => {
|
||||||
|
await expectQuery({
|
||||||
|
range: {
|
||||||
|
date: {
|
||||||
|
low: `${JAN_30TH}${SEARCH_SUFFIX}`,
|
||||||
|
high: `${JAN_30TH}${SEARCH_SUFFIX}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}).toFindNothing()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
isInternal &&
|
isInternal &&
|
||||||
|
|
Loading…
Reference in New Issue