Addressing PR comments.
This commit is contained in:
parent
70ab14319d
commit
00048a2d3e
|
@ -326,17 +326,13 @@ class InternalBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
private parseBody(body: Record<string, any>) {
|
private parseBody(body: Record<string, any>) {
|
||||||
try {
|
for (let [key, value] of Object.entries(body)) {
|
||||||
for (let [key, value] of Object.entries(body)) {
|
const { column } = this.splitter.run(key)
|
||||||
const { column } = this.splitter.run(key)
|
const schema = this.table.schema[column]
|
||||||
const schema = this.table.schema[column]
|
if (!schema) {
|
||||||
if (!schema) {
|
continue
|
||||||
continue
|
|
||||||
}
|
|
||||||
body[key] = this.parse(value, schema)
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
body[key] = this.parse(value, schema)
|
||||||
console.log(err)
|
|
||||||
}
|
}
|
||||||
return body
|
return body
|
||||||
}
|
}
|
||||||
|
|
|
@ -671,6 +671,7 @@ export class ExternalRequest<T extends Operation> {
|
||||||
config.includeSqlRelationships === IncludeRelationship.INCLUDE
|
config.includeSqlRelationships === IncludeRelationship.INCLUDE
|
||||||
|
|
||||||
// clean up row on ingress using schema
|
// clean up row on ingress using schema
|
||||||
|
const unprocessedRow = config.row
|
||||||
const processed = this.inputProcessing(row, table)
|
const processed = this.inputProcessing(row, table)
|
||||||
row = processed.row
|
row = processed.row
|
||||||
let manyRelationships = processed.manyRelationships
|
let manyRelationships = processed.manyRelationships
|
||||||
|
@ -750,9 +751,10 @@ export class ExternalRequest<T extends Operation> {
|
||||||
// we might still need to perform other operations like updating the foreign keys on other rows
|
// we might still need to perform other operations like updating the foreign keys on other rows
|
||||||
if (
|
if (
|
||||||
this.operation === Operation.UPDATE &&
|
this.operation === Operation.UPDATE &&
|
||||||
Object.keys(row || {}).length === 0
|
Object.keys(row || {}).length === 0 &&
|
||||||
|
unprocessedRow
|
||||||
) {
|
) {
|
||||||
response = [config.row!]
|
response = [unprocessedRow]
|
||||||
} else {
|
} else {
|
||||||
response = env.SQL_ALIASING_DISABLE
|
response = env.SQL_ALIASING_DISABLE
|
||||||
? await getDatasourceAndQuery(json)
|
? await getDatasourceAndQuery(json)
|
||||||
|
|
|
@ -1138,6 +1138,7 @@ describe.each([
|
||||||
status: 200,
|
status: 200,
|
||||||
})
|
})
|
||||||
expect(afterRelatedRow.relationship.length).toEqual(1)
|
expect(afterRelatedRow.relationship.length).toEqual(1)
|
||||||
|
expect(afterRelatedRow.relationship[0]._id).toEqual(row._id)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should be able to update relationships when both columns are same name", async () => {
|
it("should be able to update relationships when both columns are same name", async () => {
|
||||||
|
|
Loading…
Reference in New Issue