1
0
Fork 0
mirror of synced 2024-09-12 23:43:09 +12:00

Merge branch 'master' into feature/signature-field-and-component

This commit is contained in:
deanhannigan 2024-05-09 16:27:22 +01:00 committed by GitHub
commit 0ffa9d768a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 43 additions and 1 deletions

View file

@ -73,12 +73,15 @@ export function basicProcessing({
// filter the row down to what is actually the row (not joined)
for (let field of Object.values(table.schema)) {
const fieldName = field.name
const value = extractFieldValue({
let value = extractFieldValue({
row,
tableName: table.name,
fieldName,
isLinked,
})
if (value instanceof Buffer) {
value = value.toString()
}
// all responses include "select col as table.col" so that overlaps are handled
if (value != null) {
thisRow[fieldName] = value

View file

@ -1200,4 +1200,38 @@ describe("postgres integrations", () => {
expect(Object.keys(schema).sort()).toEqual(["id", "val1"])
})
})
describe("check custom column types", () => {
beforeAll(async () => {
await rawQuery(
rawDatasource,
`CREATE TABLE binaryTable (
id BYTEA PRIMARY KEY,
column1 TEXT,
column2 INT
);
`
)
})
it("should handle binary columns", async () => {
const response = await makeRequest(
"post",
`/api/datasources/${datasource._id}/schema`
)
expect(response.body).toBeDefined()
expect(response.body.datasource.entities).toBeDefined()
const table = response.body.datasource.entities["binarytable"]
expect(table).toBeDefined()
expect(table.schema.id.externalType).toBe("bytea")
const row = await config.api.row.save(table._id, {
id: "1111",
column1: "hello",
column2: 222,
})
expect(row._id).toBeDefined()
const decoded = decodeURIComponent(row._id!).replace(/'/g, '"')
expect(JSON.parse(decoded)[0]).toBe("1111")
})
})
})

View file

@ -192,6 +192,11 @@ export function generateRowIdField(keyProps: any[] = []) {
if (!Array.isArray(keyProps)) {
keyProps = [keyProps]
}
for (let index in keyProps) {
if (keyProps[index] instanceof Buffer) {
keyProps[index] = keyProps[index].toString()
}
}
// this conserves order and types
// we have to swap the double quotes to single quotes for use in HBS statements
// when using the literal helper the double quotes can break things