mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 08:36:44 +00:00
fix: column name ambiguous error in array operator (#4401)
* fix: column name ambiguous error in array operator * fix: test
This commit is contained in:
parent
8b3b9b3b26
commit
c3a106bcd7
@ -204,6 +204,37 @@ describe('array field operator', function () {
|
||||
expect(filter3[0].get('name')).toEqual(t2.get('name'));
|
||||
});
|
||||
|
||||
test('$anyOf with association with same column name', async () => {
|
||||
const Tag = db.collection({
|
||||
name: 'tags',
|
||||
fields: [
|
||||
{ type: 'array', name: 'type' },
|
||||
{ type: 'string', name: 'name' },
|
||||
],
|
||||
});
|
||||
|
||||
const Post = db.collection({
|
||||
name: 'posts',
|
||||
tableName: 'posts_table',
|
||||
fields: [
|
||||
{ type: 'array', name: 'type' },
|
||||
{
|
||||
type: 'hasMany',
|
||||
name: 'tags',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
await db.sync({ force: true });
|
||||
|
||||
await Post.repository.find({
|
||||
filter: {
|
||||
'type.$anyOf': ['aa'],
|
||||
'tags.name': 't1',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
// fix https://nocobase.height.app/T-2803
|
||||
test('$anyOf with string', async () => {
|
||||
const filter3 = await Test.repository.find({
|
||||
|
@ -33,15 +33,18 @@ const getFieldName = (ctx) => {
|
||||
|
||||
const model = getModelFromAssociationPath();
|
||||
|
||||
let columnPrefix = model.name;
|
||||
|
||||
if (model.rawAttributes[fieldName]) {
|
||||
columnName = model.rawAttributes[fieldName].field || fieldName;
|
||||
}
|
||||
|
||||
if (associationPath.length > 0) {
|
||||
const association = associationPath.join('->');
|
||||
columnName = `${association}.${columnName}`;
|
||||
columnPrefix = association;
|
||||
}
|
||||
|
||||
columnName = `${columnPrefix}.${columnName}`;
|
||||
return columnName;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user