Update many to many

This commit is contained in:
adrinr 2023-02-22 10:54:55 +00:00
parent e0242d0883
commit b9c54b6fe6
3 changed files with 8 additions and 11 deletions

View File

@ -629,10 +629,7 @@ export class ExternalRequest {
* Creating the specific list of fields that we desire, and excluding the ones that are no use to us
* is more performant and has the added benefit of protecting against this scenario.
*/
buildFields(
table: Table,
includeRelations: IncludeRelationship = IncludeRelationship.INCLUDE
) {
buildFields(table: Table, includeRelations: boolean) {
function extractRealFields(table: Table, existing: string[] = []) {
return Object.entries(table.schema)
.filter(
@ -691,6 +688,10 @@ export class ExternalRequest {
}
filters = buildFilters(id, filters || {}, table)
const relationships = this.buildRelationships(table)
const includeSqlRelationships =
config.includeSqlRelationships === IncludeRelationship.INCLUDE
// clean up row on ingress using schema
const processed = this.inputProcessing(row, table)
row = processed.row
@ -708,9 +709,7 @@ export class ExternalRequest {
},
resource: {
// have to specify the fields to avoid column overlap (for SQL)
fields: isSql
? this.buildFields(table, config.includeSqlRelationships)
: [],
fields: isSql ? this.buildFields(table, includeSqlRelationships) : [],
},
filters,
sort,

View File

@ -58,7 +58,7 @@ export async function patch(ctx: BBContext) {
return handleRequest(Operation.UPDATE, tableId, {
id: breakRowIdField(id),
row: inputs,
includeSqlRelationships: IncludeRelationship.EXCLUDE,
includeSqlRelationships: IncludeRelationship.INCLUDE,
})
}

View File

@ -502,9 +502,7 @@ class InternalBuilder {
if (opts.disableReturning) {
return query.update(parsedBody)
} else {
return query
.update(parsedBody)
.returning(generateSelectStatement(json, knex))
return query.update(parsedBody).returning("*")
}
}