Browse Source

fix: ts types for sql clients

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/5134/head
mertmit 2 years ago
parent
commit
ad0832ec15
  1. 2
      packages/nocodb/src/lib/db/sql-client/lib/oracle/OracleClient.ts
  2. 10
      packages/nocodb/src/lib/db/sql-mgr/SqlMgr.ts
  3. 2
      packages/nocodb/src/lib/db/sql-mgr/v2/SqlMgrv2.ts
  4. 2
      packages/nocodb/src/lib/db/sql-mgr/v2/SqlMgrv2Trans.ts
  5. 7
      packages/nocodb/src/lib/db/sql-migrator/lib/KnexMigratorv2.ts
  6. 9
      packages/nocodb/src/lib/db/sql-migrator/lib/KnexMigratorv2Tans.ts
  7. 2
      packages/nocodb/src/lib/meta/NcMetaMgr.ts
  8. 2
      packages/nocodb/src/lib/utils/common/BaseApiBuilder.ts
  9. 2
      packages/nocodb/src/lib/utils/common/NcConnectionMgr.ts
  10. 2
      packages/nocodb/src/lib/utils/common/NcConnectionMgrv2.ts

2
packages/nocodb/src/lib/db/sql-client/lib/oracle/OracleClient.ts

@ -1913,7 +1913,7 @@ class OracleClient extends KnexClient {
* @returns {Number} code
* @returns {String} message
*/
async totalRecords(_args: any = {}) {
async totalRecords(_args: any = {}): Promise<Result> {
// @ts-ignore
const func = this.totalRecords.name;
throw new Error('Function not supported for oracle yet');

10
packages/nocodb/src/lib/db/sql-mgr/SqlMgr.ts

@ -17,6 +17,14 @@ import NcConnectionMgr from '../../utils/common/NcConnectionMgr';
import { customAlphabet } from 'nanoid';
import Debug from '../util/Debug';
import Result from '../util/Result';
import type MssqlClient from '../sql-client/lib/mssql/MssqlClient';
import type MysqlClient from '../sql-client/lib/mysql/MysqlClient';
import type OracleClient from '../sql-client/lib/oracle/OracleClient';
import type PGClient from '../sql-client/lib/pg/PgClient';
import type SnowflakeClient from '../sql-client/lib/snowflake/SnowflakeClient';
import type SqliteClient from '../sql-client/lib/sqlite/SqliteClient';
const randomID = customAlphabet('1234567890abcdefghijklmnopqrstuvwxyz_', 20);
const log = new Debug('SqlMgr');
@ -337,7 +345,7 @@ export default class SqlMgr {
* @returns
* @memberof SqlMgr
*/
public async projectGetSqlClient(args) {
public async projectGetSqlClient(args): Promise<SnowflakeClient | MysqlClient | SqliteClient | MssqlClient | OracleClient | PGClient> {
const func = this.projectGetSqlClient.name;
log.api(`${func}:args:`, args);

2
packages/nocodb/src/lib/db/sql-mgr/v2/SqlMgrv2.ts

@ -118,7 +118,7 @@ export default class SqlMgrv2 {
return sqlMigrationStatements;
}
protected async getSqlClient(base: Base): Promise<any> {
protected async getSqlClient(base: Base) {
return NcConnectionMgrv2.getSqlClient(base);
}
}

2
packages/nocodb/src/lib/db/sql-mgr/v2/SqlMgrv2Trans.ts

@ -52,7 +52,7 @@ export default class SqlMgrv2Trans extends SqlMgrv2 {
}
}
protected async getSqlClient(base: Base): Promise<any> {
protected async getSqlClient(base: Base) {
return NcConnectionMgrv2.getSqlClient(base, this.trx);
}

7
packages/nocodb/src/lib/db/sql-migrator/lib/KnexMigratorv2.ts

@ -1,6 +1,7 @@
import fs from 'fs';
import path from 'path';
import { promisify } from 'util';
import { Knex } from 'knex';
import glob from 'glob';
import SqlClientFactory from '../../sql-client/lib/SqlClientFactory';
@ -428,7 +429,7 @@ export default class KnexMigratorv2 {
// }
}
protected async getSqlClient(base: Base): Promise<any> {
protected async getSqlClient(base: Base) {
return NcConnectionMgrv2.getSqlClient(base);
}
@ -753,7 +754,7 @@ export default class KnexMigratorv2 {
const vm = this;
const trx = sqlClient.knex.isTransaction
? sqlClient.knex
? sqlClient.knex as Knex.Transaction
: await sqlClient.knex.transaction();
try {
for (const query of upStatements) {
@ -920,7 +921,7 @@ export default class KnexMigratorv2 {
const vm = this;
const trx = sqlClient.knex.isTransaction
? sqlClient.knex
? sqlClient.knex as Knex.Transaction
: await sqlClient.knex.transaction();
try {
for (const query of downStatements) {

9
packages/nocodb/src/lib/db/sql-migrator/lib/KnexMigratorv2Tans.ts

@ -11,6 +11,13 @@ import Noco from '../../../Noco';
import { XKnex } from '../../sql-data-mapper';
import NcMetaIO from '../../../meta/NcMetaIO';
import type MssqlClient from '../../sql-client/lib/mssql/MssqlClient';
import type MysqlClient from '../../sql-client/lib/mysql/MysqlClient';
import type OracleClient from '../../sql-client/lib/oracle/OracleClient';
import type PGClient from '../../sql-client/lib/pg/PgClient';
import type SnowflakeClient from '../../sql-client/lib/snowflake/SnowflakeClient';
import type SqliteClient from '../../sql-client/lib/sqlite/SqliteClient';
export default class KnexMigratorv2Tans extends KnexMigratorv2 {
protected sqlClient: any;
protected ncMeta: NcMetaIO;
@ -24,7 +31,7 @@ export default class KnexMigratorv2Tans extends KnexMigratorv2 {
protected get metaDb(): XKnex {
return this.ncMeta.knex || Noco.ncMeta.knex;
}
protected async getSqlClient(base: Base): Promise<any> {
protected async getSqlClient(base: Base): Promise<SnowflakeClient | MysqlClient | SqliteClient | MssqlClient | OracleClient | PGClient> {
return this.sqlClient || NcConnectionMgrv2.getSqlClient(base);
}
}

2
packages/nocodb/src/lib/meta/NcMetaMgr.ts

@ -2909,7 +2909,7 @@ export default class NcMetaMgr {
}
}
protected async projectGetSqlClient(args): Promise<any> {
protected async projectGetSqlClient(args) {
const builder = this.getBuilder(args);
return builder?.getSqlClient();
}

2
packages/nocodb/src/lib/utils/common/BaseApiBuilder.ts

@ -187,7 +187,7 @@ export default abstract class BaseApiBuilder<T extends Noco>
return this.connectionConfig?.meta?.dbAlias;
}
public async getSqlClient(): Promise<any> {
public async getSqlClient() {
return NcConnectionMgr.getSqlClient({
dbAlias: this.dbAlias,
env: this.config.env,

2
packages/nocodb/src/lib/utils/common/NcConnectionMgr.ts

@ -149,7 +149,7 @@ export default class NcConnectionMgr {
env: string;
config: NcConfig;
projectId: string;
}): Promise<any> {
}) {
const knex = this.get({
dbAlias,
env,

2
packages/nocodb/src/lib/utils/common/NcConnectionMgrv2.ts

@ -149,7 +149,7 @@ export default class NcConnectionMgrv2 {
// return config?.envs?.[env]?.db?.find(db => db?.meta?.dbAlias === dbAlias);
// }
public static async getSqlClient(base: Base, _knex = null): Promise<any> {
public static async getSqlClient(base: Base, _knex = null) {
const knex = _knex || this.get(base);
return SqlClientFactory.create({
knex,

Loading…
Cancel
Save