Skip to content

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

chore: sync missing changes

mertmita415618b0d0a
diff --git a/packages/nc-gui/components/smartsheet/column/LinkedToAnotherRecordOptions.vue b/packages/nc-gui/components/smartsheet/column/LinkedToAnotherRecordOptions.vue
index 3ec36b2426..dec017b50a 100644
--- a/packages/nc-gui/components/smartsheet/column/LinkedToAnotherRecordOptions.vue
+++ b/packages/nc-gui/components/smartsheet/column/LinkedToAnotherRecordOptions.vue
@@ -124,7 +124,6 @@ const { baseTables } = storeToRefs(tablesStore)
const { isFeatureEnabled } = useBetaFeatureToggle()
const refTables = computed(() => {
- debugger
if (isEdit.value) {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
const refTableId = referenceTableChildId.value
diff --git a/packages/nocodb/src/dbQueryClient/generic.ts b/packages/nocodb/src/dbQueryClient/generic.ts
new file mode 100644
index 0000000000..52f3e309e7
--- /dev/null
+++ b/packages/nocodb/src/dbQueryClient/generic.ts
@@ -0,0 +1,48 @@
+import { arrFlatMap } from 'nocodb-sdk';
+import type { DBQueryClient } from '~/dbQueryClient/types';
+import type { XKnex } from '~/db/CustomKnex';
+
+export abstract class GenericDBQueryClient implements DBQueryClient {
+ temporaryTableRaw({
+ knex,
+ data,
+ fields,
+ alias,
+ }: {
+ data: Record<string, any>[];
+ fields: string[];
+ alias: string;
+ knex: XKnex;
+ }) {
+ const fieldsValuePlaceholder = `(${fields.map(() => '?').join(',')})`;
+ const valuesPlaceholder = data.map(() => fieldsValuePlaceholder).join(', ');
+ const fieldsPlaceholder = fields.map(() => '??').join(',');
+ return knex.raw(
+ `(VALUES ${valuesPlaceholder}) AS ?? (${fieldsPlaceholder})`,
+ [
+ ...arrFlatMap(
+ data.map((row) =>
+ fields.reduce((acc, field) => {
+ acc.push(row[field]);
+ return acc;
+ }, []),
+ ),
+ ),
+ alias,
+ ...fields,
+ ],
+ );
+ }
+ temporaryTable(param: {
+ data: Record<string, any>[];
+ fields: string[];
+ alias: string;
+ knex: XKnex;
+ asKnexFrom?: boolean;
+ }) {
+ return param.knex.from(this.temporaryTableRaw(param));
+ }
+
+ abstract concat(fields: string[]): string;
+ abstract simpleCast(field: string, asType: string): string;
+}
diff --git a/packages/nocodb/src/dbQueryClient/index.ts b/packages/nocodb/src/dbQueryClient/index.ts
index 8d0d0baada..1fa22329a4 100644
--- a/packages/nocodb/src/dbQueryClient/index.ts
+++ b/packages/nocodb/src/dbQueryClient/index.ts
@@ -1,5 +1,7 @@
import { ClientType } from 'nocodb-sdk';
import { PGDBQueryClient } from '~/dbQueryClient/pg';
+import { MySqlDBQueryClient } from '~/dbQueryClient/mysql';
+import { SqliteDBQueryClient } from '~/dbQueryClient/sqlite';
export class DBQueryClient {
static get(clientType: ClientType) {
@@ -7,6 +9,12 @@ export class DBQueryClient {
case ClientType.PG: {
return new PGDBQueryClient();
}
+ case ClientType.MYSQL: {
+ return new MySqlDBQueryClient();
+ }
+ case ClientType.SQLITE: {
+ return new SqliteDBQueryClient();
+ }
}
}
}
diff --git a/packages/nocodb/src/dbQueryClient/mysql.ts b/packages/nocodb/src/dbQueryClient/mysql.ts
new file mode 100644
index 0000000000..1c2f9ca7d6
--- /dev/null
+++ b/packages/nocodb/src/dbQueryClient/mysql.ts
@@ -0,0 +1,15 @@
+import type { DBQueryClient } from '~/dbQueryClient/types';
+import { GenericDBQueryClient } from '~/dbQueryClient/generic';
+
+export class MySqlDBQueryClient
+ extends GenericDBQueryClient
+ implements DBQueryClient
+{
+ concat(fields: string[]) {
+ return `CONCAT(${fields.join(', ')})`;
+ }
+ simpleCast(field: string, asType: string) {
+ const useAsType = asType.toUpperCase() === 'TEXT' ? 'CHAR' : asType;
+ return `CAST(${field} as ${useAsType})`;
+ }
+}
diff --git a/packages/nocodb/src/dbQueryClient/pg.ts b/packages/nocodb/src/dbQueryClient/pg.ts
index e20b6df5cf..59d994d434 100644
--- a/packages/nocodb/src/dbQueryClient/pg.ts
+++ b/packages/nocodb/src/dbQueryClient/pg.ts
@@ -1,35 +1,15 @@
-import { arrFlatMap } from 'nocodb-sdk';
import type { DBQueryClient } from '~/dbQueryClient/types';
-import type { XKnex } from '~/db/CustomKnex';
+import { GenericDBQueryClient } from '~/dbQueryClient/generic';
-export class PGDBQueryClient implements DBQueryClient {
- temporaryTable({
- knex,
- data,
- fields,
- alias,
- }: {
- data: Record<string, any>[];
- fields: string[];
- alias: string;
- knex: XKnex;
- }) {
- const fieldsValuePlaceholder = `(${fields.map(() => '?').join(',')})`;
- const valuesPlaceholder = data.map(() => fieldsValuePlaceholder).join(', ');
- const fieldsPlaceholder = fields.map(() => '??').join(',');
- return knex.from(
- knex.raw(`(VALUES ${valuesPlaceholder}) AS ?? (${fieldsPlaceholder})`, [
- ...arrFlatMap(
- data.map((row) =>
- fields.reduce((acc, field) => {
- acc.push(row[field]);
- return acc;
- }, []),
- ),
- ),
- alias,
- ...fields,
- ]),
- );
+export class PGDBQueryClient
+ extends GenericDBQueryClient
+ implements DBQueryClient
+{
+ concat(fields: string[]) {
+ return `CONCAT(${fields.join(', ')})`;
+ }
+
+ simpleCast(field: string, asType: string) {
+ return `${field}::${asType}`;
}
}
diff --git a/packages/nocodb/src/dbQueryClient/sqlite.ts b/packages/nocodb/src/dbQueryClient/sqlite.ts
new file mode 100644
index 0000000000..dd390cf841
--- /dev/null
+++ b/packages/nocodb/src/dbQueryClient/sqlite.ts
@@ -0,0 +1,14 @@
+import type { DBQueryClient } from '~/dbQueryClient/types';
+import { GenericDBQueryClient } from '~/dbQueryClient/generic';
+
+export class SqliteDBQueryClient
+ extends GenericDBQueryClient
+ implements DBQueryClient
+{
+ concat(fields: string[]) {
+ return `${fields.join(' || ')}`;
+ }
+ simpleCast(field: string, asType: string) {
+ return `CAST(${field} as ${asType})`;
+ }
+}
diff --git a/packages/nocodb/src/dbQueryClient/types.ts b/packages/nocodb/src/dbQueryClient/types.ts
index decae32255..d2fcf5764a 100644
--- a/packages/nocodb/src/dbQueryClient/types.ts
+++ b/packages/nocodb/src/dbQueryClient/types.ts
@@ -1,4 +1,4 @@
-import type { XKnex } from '~/db/CustomKnex';
+import type { Knex, XKnex } from '~/db/CustomKnex';
export interface DBQueryClient {
temporaryTable(payload: {
@@ -6,5 +6,15 @@ export interface DBQueryClient {
fields: string[];
alias: string;
knex: XKnex;
- });
+ }): Knex.QueryInterface;
+
+ temporaryTableRaw(payload: {
+ data: Record<string, any>[];
+ fields: string[];
+ alias: string;
+ knex: XKnex;
+ }): Knex.Raw;
+
+ concat(fields: string[]);
+ simpleCast(field: string, asType: string);
}