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