Skip to content

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

fix: group or query

Pranav C3f0291cf0cde
diff --git a/packages/nocodb/src/db/conditionV2.ts b/packages/nocodb/src/db/conditionV2.ts
index 22469bb92d..4d533c3521 100644
--- a/packages/nocodb/src/db/conditionV2.ts
+++ b/packages/nocodb/src/db/conditionV2.ts
@@ -855,13 +855,13 @@ const parseConditionV2 = async (
];
if (knex.clientType() === 'pg') {
sql =
- "(',' || ??::text || ',') ilike ? OR (',' || ??::text || ',') ilike ?";
+ "((',' || ??::text || ',') ilike ? OR (',' || ??::text || ',') ilike ?)";
} else if (knex.clientType() === 'sqlite3') {
sql =
- "(',' || ?? || ',') like ? OR (',' || ?? || ',') like ?";
+ "((',' || ?? || ',') like ? OR (',' || ?? || ',') like ?)";
} else {
sql =
- "CONCAT(',', ??, ',') like ? OR CONCAT(',', ??, ',') like ?";
+ "(CONCAT(',', ??, ',') like ? OR CONCAT(',', ??, ',') like ?)";
}
if (i === 0) {
builder = builder.where(knex.raw(sql, bindings));
diff --git a/packages/nocodb/src/db/field-handler/handlers/generic.mysql.ts b/packages/nocodb/src/db/field-handler/handlers/generic.mysql.ts
index 3ea798e46e..1afd832319 100644
--- a/packages/nocodb/src/db/field-handler/handlers/generic.mysql.ts
+++ b/packages/nocodb/src/db/field-handler/handlers/generic.mysql.ts
@@ -42,7 +42,7 @@ export class GenericMysqlFieldHandler
`%, ${items[i]},%`,
];
const sql =
- "CONCAT(',', ??, ',') like ? OR CONCAT(',', ??, ',') like ?";
+ "(CONCAT(',', ??, ',') like ? OR CONCAT(',', ??, ',') like ?)";
if (i === 0) {
builder = builder.where(knex.raw(sql, bindings));
} else {
diff --git a/packages/nocodb/src/db/field-handler/handlers/generic.pg.ts b/packages/nocodb/src/db/field-handler/handlers/generic.pg.ts
index fcb0bc0ea2..9abd617bdd 100644
--- a/packages/nocodb/src/db/field-handler/handlers/generic.pg.ts
+++ b/packages/nocodb/src/db/field-handler/handlers/generic.pg.ts
@@ -113,7 +113,7 @@ export class GenericPgFieldHandler
`%, ${items[i]},%`,
];
const sql =
- "(',' || ??::text || ',') ilike ? OR (',' || ??::text || ',') ilike ?";
+ "((',' || ??::text || ',') ilike ? OR (',' || ??::text || ',') ilike ?)";
if (i === 0) {
builder = builder.where(knex.raw(sql, bindings));
} else {
diff --git a/packages/nocodb/src/db/field-handler/handlers/generic.sqlite.ts b/packages/nocodb/src/db/field-handler/handlers/generic.sqlite.ts
index 0462472d40..825936c086 100644
--- a/packages/nocodb/src/db/field-handler/handlers/generic.sqlite.ts
+++ b/packages/nocodb/src/db/field-handler/handlers/generic.sqlite.ts
@@ -41,7 +41,7 @@ export class GenericSqliteFieldHandler
sourceField,
`%, ${items[i]},%`,
];
- const sql = "(',' || ?? || ',') like ? OR (',' || ?? || ',') like ?";
+ const sql = "((',' || ?? || ',') like ? OR (',' || ?? || ',') like ?)";
if (i === 0) {
builder = builder.where(knex.raw(sql, bindings));
} else {
diff --git a/packages/nocodb/src/db/field-handler/handlers/generic.ts b/packages/nocodb/src/db/field-handler/handlers/generic.ts
index eb4bfa7f30..5479f2849f 100644
--- a/packages/nocodb/src/db/field-handler/handlers/generic.ts
+++ b/packages/nocodb/src/db/field-handler/handlers/generic.ts
@@ -541,7 +541,7 @@ export class GenericFieldHandler
`%, ${items[i]},%`,
];
const sql =
- "CONCAT(',', ??, ',') like ? OR CONCAT(',', ??, ',') like ?";
+ "(CONCAT(',', ??, ',') like ? OR CONCAT(',', ??, ',') like ?)";
if (i === 0) {
builder = builder.where(knex.raw(sql, bindings));
} else {