diff --git a/packages/nocodb/src/dbQueryClient/generic.ts b/packages/nocodb/src/dbQueryClient/generic.ts index 85753f074f..564d0480d8 100644 --- a/packages/nocodb/src/dbQueryClient/generic.ts +++ b/packages/nocodb/src/dbQueryClient/generic.ts @@ -1,9 +1,17 @@ -import { arrFlatMap } from 'nocodb-sdk'; +import { arrFlatMap, ClientType } from 'nocodb-sdk'; import type { DBQueryClient } from '~/dbQueryClient/types'; import type { Knex, XKnex } from '~/db/CustomKnex'; import type { PagedResponseImpl } from '~/helpers/PagedResponse'; export abstract class GenericDBQueryClient implements DBQueryClient { + get clientType(): ClientType { + return ClientType.PG; + } + validateClientType(client: string) { + if (client !== this.clientType) { + throw new Error('Source is not ' + this.clientType); + } + } temporaryTableRaw({ knex, data, diff --git a/packages/nocodb/src/dbQueryClient/mysql.ts b/packages/nocodb/src/dbQueryClient/mysql.ts index 1c2f9ca7d6..832b5c02b4 100644 --- a/packages/nocodb/src/dbQueryClient/mysql.ts +++ b/packages/nocodb/src/dbQueryClient/mysql.ts @@ -1,3 +1,4 @@ +import { ClientType } from 'nocodb-sdk'; import type { DBQueryClient } from '~/dbQueryClient/types'; import { GenericDBQueryClient } from '~/dbQueryClient/generic'; @@ -5,6 +6,15 @@ export class MySqlDBQueryClient extends GenericDBQueryClient implements DBQueryClient { + get clientType(): ClientType { + return ClientType.MYSQL; + } + validateClientType(client: string) { + if (!['mysql', 'mysql2'].includes(client)) { + throw new Error('Source is not ' + this.clientType); + } + } + concat(fields: string[]) { return `CONCAT(${fields.join(', ')})`; } diff --git a/packages/nocodb/src/dbQueryClient/pg.ts b/packages/nocodb/src/dbQueryClient/pg.ts index 59d994d434..b615bcb675 100644 --- a/packages/nocodb/src/dbQueryClient/pg.ts +++ b/packages/nocodb/src/dbQueryClient/pg.ts @@ -1,3 +1,4 @@ +import { ClientType } from 'nocodb-sdk'; import type { DBQueryClient } from '~/dbQueryClient/types'; import { GenericDBQueryClient } from '~/dbQueryClient/generic'; @@ -5,6 +6,10 @@ export class PGDBQueryClient extends GenericDBQueryClient implements DBQueryClient { + get clientType(): ClientType { + return ClientType.PG; + } + concat(fields: string[]) { return `CONCAT(${fields.join(', ')})`; } diff --git a/packages/nocodb/src/dbQueryClient/sqlite.ts b/packages/nocodb/src/dbQueryClient/sqlite.ts index dd390cf841..292e7c2f18 100644 --- a/packages/nocodb/src/dbQueryClient/sqlite.ts +++ b/packages/nocodb/src/dbQueryClient/sqlite.ts @@ -1,3 +1,4 @@ +import { ClientType } from 'nocodb-sdk'; import type { DBQueryClient } from '~/dbQueryClient/types'; import { GenericDBQueryClient } from '~/dbQueryClient/generic'; @@ -5,6 +6,9 @@ export class SqliteDBQueryClient extends GenericDBQueryClient implements DBQueryClient { + get clientType(): ClientType { + return ClientType.SQLITE; + } concat(fields: string[]) { return `${fields.join(' || ')}`; } diff --git a/packages/nocodb/src/dbQueryClient/types.ts b/packages/nocodb/src/dbQueryClient/types.ts index d2fcf5764a..bd1180f9f7 100644 --- a/packages/nocodb/src/dbQueryClient/types.ts +++ b/packages/nocodb/src/dbQueryClient/types.ts @@ -1,6 +1,9 @@ +import type { ClientType } from 'nocodb-sdk'; import type { Knex, XKnex } from '~/db/CustomKnex'; export interface DBQueryClient { + get clientType(): ClientType; + validateClientType(client: string): void; temporaryTable(payload: { data: Record[]; fields: string[];