mirror of
https://github.com/nocodb/nocodb.git
synced 2026-02-01 22:08:33 +00:00
Merge pull request #12960 from nocodb/nc-refactor/unified-query-list-read
unify single query list / read
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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(', ')})`;
|
||||
}
|
||||
|
||||
@@ -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(', ')})`;
|
||||
}
|
||||
|
||||
@@ -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(' || ')}`;
|
||||
}
|
||||
|
||||
@@ -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<string, any>[];
|
||||
fields: string[];
|
||||
|
||||
Reference in New Issue
Block a user