Add more AUTO tests.
This commit is contained in:
parent
289de5906a
commit
8b2156ed08
|
@ -19,15 +19,16 @@ import _ from "lodash"
|
|||
jest.unmock("mssql")
|
||||
|
||||
describe.each([
|
||||
// ["internal", undefined],
|
||||
// ["internal-sqs", undefined],
|
||||
[DatabaseName.POSTGRES, getDatasource(DatabaseName.POSTGRES)],
|
||||
// ["lucene", undefined],
|
||||
["sqs", undefined],
|
||||
// [DatabaseName.POSTGRES, getDatasource(DatabaseName.POSTGRES)],
|
||||
// [DatabaseName.MYSQL, getDatasource(DatabaseName.MYSQL)],
|
||||
// [DatabaseName.SQL_SERVER, getDatasource(DatabaseName.SQL_SERVER)],
|
||||
// [DatabaseName.MARIADB, getDatasource(DatabaseName.MARIADB)],
|
||||
])("/api/:sourceId/search (%s)", (name, dsProvider) => {
|
||||
const isSqs = name === "internal-sqs"
|
||||
const isInternal = name === "internal"
|
||||
const isSqs = name === "sqs"
|
||||
const isLucene = name === "lucene"
|
||||
const isInternal = isSqs || isLucene
|
||||
const config = setup.getConfig()
|
||||
|
||||
let envCleanup: (() => void) | undefined
|
||||
|
@ -60,7 +61,7 @@ describe.each([
|
|||
}
|
||||
|
||||
async function createRows(rows: Record<string, any>[]) {
|
||||
await Promise.all(rows.map(r => config.api.row.save(table._id!, r)))
|
||||
await config.api.row.bulkImport(table._id!, { rows })
|
||||
}
|
||||
|
||||
class SearchAssertion {
|
||||
|
@ -340,14 +341,14 @@ describe.each([
|
|||
}).toFindNothing())
|
||||
|
||||
// We never implemented half-open ranges in Lucene.
|
||||
!isInternal &&
|
||||
!isLucene &&
|
||||
it("can search using just a low value", () =>
|
||||
expectQuery({
|
||||
range: { age: { low: 5 } },
|
||||
}).toContainExactly([{ age: 10 }]))
|
||||
|
||||
// We never implemented half-open ranges in Lucene.
|
||||
!isInternal &&
|
||||
!isLucene &&
|
||||
it("can search using just a high value", () =>
|
||||
expectQuery({
|
||||
range: { age: { high: 5 } },
|
||||
|
@ -458,14 +459,14 @@ describe.each([
|
|||
}).toFindNothing())
|
||||
|
||||
// We never implemented half-open ranges in Lucene.
|
||||
!isInternal &&
|
||||
!isLucene &&
|
||||
it("can search using just a low value", () =>
|
||||
expectQuery({
|
||||
range: { dob: { low: JAN_5TH } },
|
||||
}).toContainExactly([{ dob: JAN_10TH }]))
|
||||
|
||||
// We never implemented half-open ranges in Lucene.
|
||||
!isInternal &&
|
||||
!isLucene &&
|
||||
it("can search using just a high value", () =>
|
||||
expectQuery({
|
||||
range: { dob: { high: JAN_5TH } },
|
||||
|
@ -643,7 +644,7 @@ describe.each([
|
|||
// Range searches against bigints don't seem to work at all in Lucene, and I
|
||||
// couldn't figure out why. Given that we're replacing Lucene with SQS,
|
||||
// we've decided not to spend time on it.
|
||||
!isInternal &&
|
||||
!isLucene &&
|
||||
describe("range", () => {
|
||||
it("successfully finds a row", () =>
|
||||
expectQuery({
|
||||
|
@ -678,7 +679,7 @@ describe.each([
|
|||
})
|
||||
|
||||
isInternal &&
|
||||
describe.only("auto", () => {
|
||||
describe("auto", () => {
|
||||
beforeAll(async () => {
|
||||
await createTable({
|
||||
auto: {
|
||||
|
@ -698,5 +699,62 @@ describe.each([
|
|||
it("fails to find nonexistent row", () =>
|
||||
expectQuery({ equal: { auto: 0 } }).toFindNothing())
|
||||
})
|
||||
|
||||
describe("not equal", () => {
|
||||
it("successfully finds a row", () =>
|
||||
expectQuery({ notEqual: { auto: 1 } }).toContainExactly([
|
||||
{ auto: 2 },
|
||||
{ auto: 3 },
|
||||
]))
|
||||
|
||||
it("fails to find nonexistent row", () =>
|
||||
expectQuery({ notEqual: { auto: 0 } }).toContainExactly([
|
||||
{ auto: 1 },
|
||||
{ auto: 2 },
|
||||
{ auto: 3 },
|
||||
]))
|
||||
})
|
||||
|
||||
describe("oneOf", () => {
|
||||
it("successfully finds a row", () =>
|
||||
expectQuery({ oneOf: { auto: [1] } }).toContainExactly([{ auto: 1 }]))
|
||||
|
||||
it("fails to find nonexistent row", () =>
|
||||
expectQuery({ oneOf: { auto: [0] } }).toFindNothing())
|
||||
})
|
||||
|
||||
describe("range", () => {
|
||||
it("successfully finds a row", () =>
|
||||
expectQuery({
|
||||
range: { auto: { low: 1, high: 1 } },
|
||||
}).toContainExactly([{ auto: 1 }]))
|
||||
|
||||
it("successfully finds multiple rows", () =>
|
||||
expectQuery({
|
||||
range: { auto: { low: 1, high: 2 } },
|
||||
}).toContainExactly([{ auto: 1 }, { auto: 2 }]))
|
||||
|
||||
it("successfully finds a row with a high bound", () =>
|
||||
expectQuery({
|
||||
range: { auto: { low: 2, high: 2 } },
|
||||
}).toContainExactly([{ auto: 2 }]))
|
||||
|
||||
it("successfully finds no rows", () =>
|
||||
expectQuery({
|
||||
range: { auto: { low: 0, high: 0 } },
|
||||
}).toFindNothing())
|
||||
|
||||
isSqs &&
|
||||
it("can search using just a low value", () =>
|
||||
expectQuery({
|
||||
range: { auto: { low: 2 } },
|
||||
}).toContainExactly([{ auto: 2 }, { auto: 3 }]))
|
||||
|
||||
isSqs &&
|
||||
it("can search using just a high value", () =>
|
||||
expectQuery({
|
||||
range: { auto: { high: 2 } },
|
||||
}).toContainExactly([{ auto: 1 }, { auto: 2 }]))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -33,7 +33,7 @@ const FieldTypeMap: Record<FieldType, SQLiteType> = {
|
|||
[FieldType.LONGFORM]: SQLiteType.TEXT,
|
||||
[FieldType.NUMBER]: SQLiteType.REAL,
|
||||
[FieldType.STRING]: SQLiteType.TEXT,
|
||||
[FieldType.AUTO]: SQLiteType.TEXT,
|
||||
[FieldType.AUTO]: SQLiteType.REAL,
|
||||
[FieldType.OPTIONS]: SQLiteType.TEXT,
|
||||
[FieldType.JSON]: SQLiteType.BLOB,
|
||||
[FieldType.INTERNAL]: SQLiteType.BLOB,
|
||||
|
|
Loading…
Reference in New Issue