In progress: bigint tests.
This commit is contained in:
parent
66fa1538a4
commit
253fa0def8
|
@ -18,14 +18,15 @@ import _ from "lodash"
|
|||
jest.unmock("mssql")
|
||||
|
||||
describe.each([
|
||||
["internal", undefined],
|
||||
// ["internal", undefined],
|
||||
["internal-sqs", undefined],
|
||||
[DatabaseName.POSTGRES, getDatasource(DatabaseName.POSTGRES)],
|
||||
[DatabaseName.MYSQL, getDatasource(DatabaseName.MYSQL)],
|
||||
[DatabaseName.SQL_SERVER, getDatasource(DatabaseName.SQL_SERVER)],
|
||||
[DatabaseName.MARIADB, getDatasource(DatabaseName.MARIADB)],
|
||||
// [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 config = setup.getConfig()
|
||||
|
||||
let envCleanup: (() => void) | undefined
|
||||
|
@ -550,4 +551,90 @@ describe.each([
|
|||
]))
|
||||
})
|
||||
})
|
||||
|
||||
describe("bigints", () => {
|
||||
const SMALL = "1"
|
||||
const MEDIUM = "10000000"
|
||||
|
||||
// Our bigints are int64s in most datasources.
|
||||
const BIG = "9223372036854775807"
|
||||
|
||||
beforeAll(async () => {
|
||||
await createTable({
|
||||
num: { name: "num", type: FieldType.BIGINT },
|
||||
})
|
||||
await createRows([{ num: SMALL }, { num: MEDIUM }, { num: BIG }])
|
||||
})
|
||||
|
||||
describe("equal", () => {
|
||||
it("successfully finds a row", () =>
|
||||
expectQuery({ equal: { num: SMALL } }).toContainExactly([
|
||||
{ num: SMALL },
|
||||
]))
|
||||
|
||||
it("successfully finds a big value", () =>
|
||||
expectQuery({ equal: { num: BIG } }).toContainExactly([{ num: BIG }]))
|
||||
|
||||
it("fails to find nonexistent row", () =>
|
||||
expectQuery({ equal: { num: "2" } }).toFindNothing())
|
||||
})
|
||||
|
||||
describe("notEqual", () => {
|
||||
it("successfully finds a row", () =>
|
||||
expectQuery({ notEqual: { num: SMALL } }).toContainExactly([
|
||||
{ num: MEDIUM },
|
||||
{ num: BIG },
|
||||
]))
|
||||
|
||||
it("fails to find nonexistent row", () =>
|
||||
expectQuery({ notEqual: { num: 10 } }).toContainExactly([
|
||||
{ num: SMALL },
|
||||
{ num: MEDIUM },
|
||||
{ num: BIG },
|
||||
]))
|
||||
})
|
||||
|
||||
describe("oneOf", () => {
|
||||
it("successfully finds a row", () =>
|
||||
expectQuery({ oneOf: { num: [SMALL] } }).toContainExactly([
|
||||
{ num: SMALL },
|
||||
]))
|
||||
|
||||
it("successfully finds all rows", () =>
|
||||
expectQuery({ oneOf: { num: [SMALL, MEDIUM, BIG] } }).toContainExactly([
|
||||
{ num: SMALL },
|
||||
{ num: MEDIUM },
|
||||
{ num: BIG },
|
||||
]))
|
||||
|
||||
it("fails to find nonexistent row", () =>
|
||||
expectQuery({ oneOf: { num: [2] } }).toFindNothing())
|
||||
})
|
||||
|
||||
// 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 &&
|
||||
describe("range", () => {
|
||||
it.only("successfully finds a row", () =>
|
||||
expectQuery({
|
||||
range: { num: { low: SMALL, high: "5" } },
|
||||
}).toContainExactly([{ num: SMALL }]))
|
||||
|
||||
it("successfully finds multiple rows", () =>
|
||||
expectQuery({
|
||||
range: { num: { low: SMALL, high: MEDIUM } },
|
||||
}).toContainExactly([{ num: SMALL }, { num: MEDIUM }]))
|
||||
|
||||
it("successfully finds a row with a high bound", () =>
|
||||
expectQuery({
|
||||
range: { num: { low: MEDIUM, high: BIG } },
|
||||
}).toContainExactly([{ num: MEDIUM }, { num: BIG }]))
|
||||
|
||||
it("successfully finds no rows", () =>
|
||||
expectQuery({
|
||||
range: { num: { low: "5", high: "5" } },
|
||||
}).toFindNothing())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -52,6 +52,12 @@ export async function save(
|
|||
!oldTable &&
|
||||
(tableToSave.primary == null || tableToSave.primary.length === 0)
|
||||
) {
|
||||
if (tableToSave.schema.id) {
|
||||
throw new Error(
|
||||
"External tables with no `primary` column set will define an `id` column, but we found an `id` column in the supplied schema. Either set a `primary` column or remove the `id` column."
|
||||
)
|
||||
}
|
||||
|
||||
tableToSave.primary = ["id"]
|
||||
tableToSave.schema.id = {
|
||||
type: FieldType.NUMBER,
|
||||
|
|
|
@ -31,7 +31,7 @@ const FieldTypeMap: Record<FieldType, SQLiteType> = {
|
|||
[FieldType.ATTACHMENT_SINGLE]: SQLiteType.BLOB,
|
||||
[FieldType.ARRAY]: SQLiteType.BLOB,
|
||||
[FieldType.LINK]: SQLiteType.BLOB,
|
||||
[FieldType.BIGINT]: SQLiteType.REAL,
|
||||
[FieldType.BIGINT]: SQLiteType.TEXT,
|
||||
// TODO: consider the difference between multi-user and single user types (subtyping)
|
||||
[FieldType.BB_REFERENCE]: SQLiteType.TEXT,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue