Browse Source

Merge pull request #1757 from nocodb/fix/1756-ltar-based-filter

Fix - LTAR based filter
pull/1771/head
աɨռɢӄաօռɢ 3 years ago committed by GitHub
parent
commit
d5aa171310
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSqlv2.ts
  2. 14
      packages/nocodb/src/lib/dataMapper/lib/sql/conditionV2.ts

22
packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSqlv2.ts

@ -1864,10 +1864,13 @@ class BaseModelSqlv2 {
{
await this.dbDriver(childTable.table_name)
.update({
[childColumn.column_name]: this.dbDriver(parentTable.table_name)
.select(parentColumn.column_name)
.where(_wherePk(parentTable.primaryKeys, rowId))
.first()
[childColumn.column_name]: this.dbDriver.from(
this.dbDriver(parentTable.table_name)
.select(parentColumn.column_name)
.where(_wherePk(parentTable.primaryKeys, rowId))
.first()
.as('___cn_alias')
)
})
.where(_wherePk(childTable.primaryKeys, childId));
}
@ -1876,10 +1879,13 @@ class BaseModelSqlv2 {
{
await this.dbDriver(childTable.table_name)
.update({
[childColumn.column_name]: this.dbDriver(parentTable.table_name)
.select(parentColumn.column_name)
.where(_wherePk(parentTable.primaryKeys, childId))
.first()
[childColumn.column_name]: this.dbDriver.from(
this.dbDriver(parentTable.table_name)
.select(parentColumn.column_name)
.where(_wherePk(parentTable.primaryKeys, childId))
.first()
.as('___cn_alias')
)
})
.where(_wherePk(childTable.primaryKeys, rowId));
}

14
packages/nocodb/src/lib/dataMapper/lib/sql/conditionV2.ts

@ -110,7 +110,7 @@ const parseConditionV2 = async (
};
} else if (colOptions.type === RelationTypes.BELONGS_TO) {
const selectQb = knex(parentModel.table_name).select(
childColumn.column_name
parentColumn.column_name
);
(
await parseConditionV2(
@ -323,7 +323,7 @@ async function generateLookupCondition(
const parentModel = await parentColumn.getModel();
await parentModel.getColumns();
if (relationColumnOptions.type === 'hm') {
if (relationColumnOptions.type === RelationTypes.HAS_MANY) {
qb = knex(`${childModel.table_name} as ${alias}`);
qb.select(`${alias}.${childColumn.column_name}`);
@ -347,7 +347,7 @@ async function generateLookupCondition(
qbP.whereNotIn(parentColumn.column_name, qb);
else qbP.whereIn(parentColumn.column_name, qb);
};
} else if (relationColumnOptions.type === 'bt') {
} else if (relationColumnOptions.type === RelationTypes.BELONGS_TO) {
qb = knex(`${parentModel.table_name} as ${alias}`);
qb.select(`${alias}.${childColumn.column_name}`);
@ -439,7 +439,7 @@ async function nestedConditionJoin(
await parentModel.getColumns();
{
switch (relationColOptions.type) {
case 'hm':
case RelationTypes.HAS_MANY:
{
qb.join(
`${childModel.table_name} as ${relAlias}`,
@ -448,7 +448,7 @@ async function nestedConditionJoin(
);
}
break;
case 'bt':
case RelationTypes.BELONGS_TO:
{
qb.join(
`${parentModel.table_name} as ${relAlias}`,
@ -492,7 +492,7 @@ async function nestedConditionJoin(
);
} else {
switch (relationColOptions.type) {
case 'hm':
case RelationTypes.HAS_MANY:
{
(
await parseConditionV2(
@ -508,7 +508,7 @@ async function nestedConditionJoin(
)(qb);
}
break;
case 'bt':
case RelationTypes.BELONGS_TO:
{
(
await parseConditionV2(

Loading…
Cancel
Save