Merge remote-tracking branch 'origin/main' into next

This commit is contained in:
Chareice 2024-11-26 17:12:36 +08:00
commit 548cfe3e56
No known key found for this signature in database
3 changed files with 6 additions and 4 deletions

View File

@ -127,6 +127,8 @@ describe('view inference', function () {
});
const createdAt = UserCollection.model.rawAttributes['createdAt'].field;
expect(inferredFields[createdAt]['field']).toBeDefined();
if (db.isMySQLCompatibleDialect()) {
expect(inferredFields[createdAt]['type']).toBe('datetimeNoTz');
} else {

View File

@ -52,7 +52,7 @@ export class ViewFieldInference {
const rawFields = [];
for (const [name, column] of Object.entries(columns)) {
const inferResult: any = { name, rawType: column.type };
const inferResult: any = { name, rawType: column.type, field: name };
const usage = columnUsage[name];

View File

@ -450,7 +450,7 @@ describe('view collection', function () {
const dropViewSQL = `DROP VIEW IF EXISTS test_view`;
await db.sequelize.query(dropViewSQL);
const viewSQL = `CREATE VIEW test_view AS select 1+1 as "Uppercase"`;
const viewSQL = `CREATE VIEW test_view AS select 1+1 as "t_Uppercase"`;
await db.sequelize.query(viewSQL);
await collectionRepository.create({
@ -458,7 +458,7 @@ describe('view collection', function () {
name: 'view_collection',
viewName: 'test_view',
isView: true,
fields: [{ type: 'string', name: 'upper_case', field: 'Uppercase' }],
fields: [{ type: 'string', name: 'upper_case', field: 't_Uppercase' }],
schema: db.inDialect('postgres') ? 'public' : undefined,
},
context: {},
@ -466,7 +466,7 @@ describe('view collection', function () {
const viewCollection = db.getCollection('view_collection');
expect(viewCollection.model.rawAttributes['upper_case'].field).toEqual('Uppercase');
expect(viewCollection.model.rawAttributes['upper_case'].field).toEqual('t_Uppercase');
const results = await viewCollection.repository.find();
expect(results.length).toBe(1);
});