Updating based on PR comments.

This commit is contained in:
mike12345567 2024-03-22 15:26:02 +00:00
parent defb925d16
commit cc8a0274a4
3 changed files with 14 additions and 35 deletions

View File

@ -149,11 +149,9 @@ function enrichParameters(
// first check parameters are all valid
validateQueryInputs(requestParameters)
// make sure parameters are fully enriched with defaults
for (let parameter of query.parameters) {
let value: string | null = requestParameters[parameter.name]
if (!value) {
value = parameter.default
}
for (const parameter of query.parameters) {
let value: string | null =
requestParameters[parameter.name] || parameter.default
if (query.nullDefaultSupport && paramNotSet(value)) {
value = null
}

View File

@ -34,30 +34,12 @@ const createTableSQL: Record<string, string> = {
const insertSQL = `INSERT INTO test_table (name) VALUES ('one'), ('two'), ('three'), ('four'), ('five')`
const dropTableSQL = `DROP TABLE test_table;`
const POSTGRES_SPECIFICS = {
nullError: 'invalid input syntax for type integer: ""',
}
const MYSQL_SPECIFICS = {
nullError: "Incorrect integer value: '' for column 'number' at row 1",
}
const MSSQL_SPECIFICS = {
// MS-SQL doesn't throw an error here, it casts empty string to nothing
nullError: undefined,
}
const MARIADB_SPECIFICS = {
nullError:
"Incorrect integer value: '' for column `mysql`.`test_table`.`number` at row 1",
}
describe.each([
["postgres", databaseTestProviders.postgres, POSTGRES_SPECIFICS],
["mysql", databaseTestProviders.mysql, MYSQL_SPECIFICS],
["mssql", databaseTestProviders.mssql, MSSQL_SPECIFICS],
["mariadb", databaseTestProviders.mariadb, MARIADB_SPECIFICS],
])("queries (%s)", (__, dsProvider, testSpecificInformation) => {
["postgres", databaseTestProviders.postgres],
["mysql", databaseTestProviders.mysql],
["mssql", databaseTestProviders.mssql],
["mariadb", databaseTestProviders.mariadb],
])("queries (%s)", (dbName, dsProvider) => {
const config = setup.getConfig()
let datasource: Datasource
@ -461,12 +443,11 @@ describe.each([
} catch (err: any) {
error = err.message
}
const testExpectation = testSpecificInformation.nullError
if (testExpectation) {
expect(error).toBeDefined()
expect(error).toContain(testExpectation)
} else {
if (dbName === "mssql") {
expect(error).toBeUndefined()
} else {
expect(error).toBeDefined()
expect(error).toContain("integer")
}
})

View File

@ -70,8 +70,8 @@ export async function enrichArrayContext(
inputs = {}
): Promise<any[]> {
const map: Record<string, any> = {}
for (let [key, value] of Object.entries(fields)) {
map[key] = value
for (let index in fields) {
map[index] = fields[index]
}
const output = await enrichContext(map, inputs)
const outputArray: any[] = []