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