Browse Source

Merge pull request #9899 from nocodb/nc-fix/oo-is-blank

fix: use alias when constructing hm filter query to avoid self-reference issue
pull/9903/head
Pranav C 2 days ago committed by GitHub
parent
commit
dea7de609a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 22
      packages/nocodb/src/db/conditionV2.ts

22
packages/nocodb/src/db/conditionV2.ts

@ -213,30 +213,18 @@ const parseConditionV2 = async (
filter.comparison_op,
)
) {
// handle self reference
if (parentModel.id === childModel.id) {
if (filter.comparison_op === 'blank') {
return (qb) => {
qb.whereNull(childColumn.column_name);
};
} else {
return (qb) => {
qb.whereNotNull(childColumn.column_name);
};
}
}
const childTableAlias = getAlias(aliasCount);
const selectHmCount = knex(
baseModelSqlv2.getTnPath(childModel.table_name),
baseModelSqlv2.getTnPath(childModel.table_name, childTableAlias),
)
.count(childColumn.column_name)
.where(
.whereRaw('??.?? = ??.??', [
childTableAlias,
childColumn.column_name,
knex.raw('??.??', [
alias || baseModelSqlv2.getTnPath(parentModel.table_name),
parentColumn.column_name,
]),
);
]);
return (qb) => {
if (filter.comparison_op === 'blank') {

Loading…
Cancel
Save