fix(backend): __disambiguation__

This commit is contained in:
Acid Chicken (硫酸鶏) 2024-05-29 18:16:10 +09:00
parent c8ac5a7e2b
commit 0d8a88b2c8
No known key found for this signature in database
GPG Key ID: 3E87B98A3F6BAB99
1 changed files with 4 additions and 4 deletions

View File

@ -84,16 +84,16 @@ export const miRepository = {
// @ts-expect-error -- protected
const insertedColumns = queryBuilder.getInsertedColumns();
if (insertedColumns.length) {
return insertedColumns.map(column => column.databaseName);
return insertedColumns.map(column => `__disambiguation__${column.databaseName}`);
}
if (!queryBuilder.expressionMap.mainAlias?.hasMetadata && !queryBuilder.expressionMap.insertColumns.length) {
// @ts-expect-error -- protected
const valueSets = queryBuilder.getValueSets();
if (valueSets.length === 1) {
return Object.keys(valueSets[0]);
return Object.keys(valueSets[0]).map(key => `__disambiguation__${key}`);
}
}
return queryBuilder.expressionMap.insertColumns;
return queryBuilder.expressionMap.insertColumns.map(column => `__disambiguation__${column}`);
},
async insertOne(entity, findOptions?) {
const queryBuilder = this.createQueryBuilder().insert().values(entity).returning('*');
@ -115,7 +115,7 @@ export const miRepository = {
return builder.select(selection, selectionAliasName);
};
for (const columnName of this.createTableColumnNames(queryBuilder)) {
selectOrAddSelect(`${builder.alias}.${columnName}`, `${builder.alias}_${columnName}`);
selectOrAddSelect(`${builder.alias}.${columnName}`, `${builder.alias}_${columnName.slice('__disambiguation__'.length)}`);
}
},
} satisfies MiRepository<ObjectLiteral>;