|
|
|
@ -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( |
|
|
|
|