Merge pull request #1982 from Budibase/fix/query-array-pg

fix postgres query array value
This commit is contained in:
Martin McKeaveney 2021-07-13 17:45:13 +01:00 committed by GitHub
commit 47ba22eb58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 8 deletions

View File

@ -99,9 +99,11 @@ export interface QueryJson {
export interface SqlQuery {
sql: string
bindings?: {
[key: string]: any
}
bindings?:
| string[]
| {
[key: string]: any
}
}
export interface QueryOptions {

View File

@ -92,7 +92,7 @@ module PostgresModule {
async function internalQuery(client: any, query: SqlQuery) {
try {
return await client.query(query.sql, query.bindings || {})
return await client.query(query.sql, query.bindings || [])
} catch (err) {
throw new Error(err)
}

View File

@ -20,7 +20,7 @@ describe("Postgres Integration", () => {
const response = await config.integration.create({
sql
})
expect(pg.queryMock).toHaveBeenCalledWith(sql, {})
expect(pg.queryMock).toHaveBeenCalledWith(sql, [])
})
it("calls the read method with the correct params", async () => {
@ -28,7 +28,7 @@ describe("Postgres Integration", () => {
const response = await config.integration.read({
sql
})
expect(pg.queryMock).toHaveBeenCalledWith(sql, {})
expect(pg.queryMock).toHaveBeenCalledWith(sql, [])
})
it("calls the update method with the correct params", async () => {
@ -36,7 +36,7 @@ describe("Postgres Integration", () => {
const response = await config.integration.update({
sql
})
expect(pg.queryMock).toHaveBeenCalledWith(sql, {})
expect(pg.queryMock).toHaveBeenCalledWith(sql, [])
})
it("calls the delete method with the correct params", async () => {
@ -44,7 +44,7 @@ describe("Postgres Integration", () => {
await config.integration.delete({
sql
})
expect(pg.queryMock).toHaveBeenCalledWith(sql, {})
expect(pg.queryMock).toHaveBeenCalledWith(sql, [])
})
describe("no rows returned", () => {