Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

fix considering null in nanyof

Fendy Heryantoeb1a63363483
diff --git a/packages/nocodb/src/db/BaseModelSqlv2.ts b/packages/nocodb/src/db/BaseModelSqlv2.ts
index 08da8531d6..fe63a413f5 100644
--- a/packages/nocodb/src/db/BaseModelSqlv2.ts
+++ b/packages/nocodb/src/db/BaseModelSqlv2.ts
@@ -144,6 +144,8 @@ import { supportsThumbnails } from '~/utils/attachmentUtils';
import { Profiler } from '~/helpers/profiler';
import { isTransientError } from '~/helpers/db-error/utils';
+const debugCount = debug('nc:db:query:basemodel:count');
+
dayjs.extend(utc);
dayjs.extend(timezone);
@@ -759,6 +761,13 @@ class BaseModelSqlv2 implements IBaseModelSqlV2 {
);
}
+ debugCount(
+ qb
+ .count(sanitize(this.model.primaryKey?.column_name) || '*', {
+ as: 'count',
+ })
+ .toQuery(),
+ );
qb.count(sanitize(this.model.primaryKey?.column_name) || '*', {
as: 'count',
}).first();
diff --git a/packages/nocodb/src/db/field-handler/handlers/lookup/lookup.general.handler.ts b/packages/nocodb/src/db/field-handler/handlers/lookup/lookup.general.handler.ts
index 2bee9ff27f..a273d47749 100644
--- a/packages/nocodb/src/db/field-handler/handlers/lookup/lookup.general.handler.ts
+++ b/packages/nocodb/src/db/field-handler/handlers/lookup/lookup.general.handler.ts
@@ -118,6 +118,7 @@ export class LookupGeneralHandler extends ComputedFieldHandler {
);
qb.select(`${alias}.${childColumn.column_name}`);
+ qb.whereNotNull(`${alias}.${childColumn.column_name}`);
}
const conditionJoinResult = await nestedConditionJoin({
@@ -186,6 +187,7 @@ export class LookupGeneralHandler extends ComputedFieldHandler {
]),
);
qb.select(`${alias}.${parentColumn.column_name}`);
+ qb.whereNotNull(`${alias}.${parentColumn.column_name}`);
}
const conditionJoinResult = await nestedConditionJoin({
@@ -252,6 +254,7 @@ export class LookupGeneralHandler extends ComputedFieldHandler {
]),
)
.select(`${alias}.${mmChildColumn.column_name}`)
+ .whereNotNull(`${alias}.${mmChildColumn.column_name}`)
.join(
knex.raw(`?? as ??`, [
parentBaseModel.getTnPath(parentModel.table_name),