diff --git a/packages/nocodb/src/lib/Noco.ts b/packages/nocodb/src/lib/Noco.ts index 4094793455..7e5bc855a3 100644 --- a/packages/nocodb/src/lib/Noco.ts +++ b/packages/nocodb/src/lib/Noco.ts @@ -81,12 +81,10 @@ export default class Noco { return Noco._this.router; } Noco._this = new Noco(); - Noco.initialized = true; return Noco._this.init(args, server, app); } private static config: NcConfig; - public static initialized: boolean; public readonly router: express.Router; public readonly projectRouter: express.Router; public static _ncMeta: NcMetaIO; diff --git a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts index ed3d0542d4..8d915fe97a 100644 --- a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts +++ b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts @@ -1786,7 +1786,7 @@ class BaseModelSqlv2 { queryResponse = (await qb) as any; } - const count = queryResponse.count || queryResponse; + const count = queryResponse ?? 0; await this.afterBulkUpdate(count, this.dbDriver, cookie); return count; @@ -1853,9 +1853,8 @@ class BaseModelSqlv2 { this.dbDriver ); qb.del(); - const queryResponse = (await qb) as any; + const count = (await qb) as any; - const count = queryResponse.count || queryResponse; await this.afterBulkDelete(count, this.dbDriver, cookie); return count; diff --git a/packages/nocodb/tests/unit/TestDbMngr.ts b/packages/nocodb/tests/unit/TestDbMngr.ts index 2bf23f0b82..c13199de3f 100644 --- a/packages/nocodb/tests/unit/TestDbMngr.ts +++ b/packages/nocodb/tests/unit/TestDbMngr.ts @@ -30,33 +30,16 @@ export default class TestDbMngr { } } - static async init({ - user = TestDbMngr.defaultConnection.user, - password = TestDbMngr.defaultConnection.password, - host = TestDbMngr.defaultConnection.host, - port = TestDbMngr.defaultConnection.port, - client = TestDbMngr.defaultConnection.client, - } = {}) { - if(await TestDbMngr.isMysqlConfigured({ user, password, host, port, client })){ - await TestDbMngr.connectMysql({ user, password, host, port, client }); + static async init() { + if(await TestDbMngr.isMysqlConfigured()){ + await TestDbMngr.connectMysql(); } else { await TestDbMngr.switchToSqlite(); } } - static async isMysqlConfigured({ - user, - password, - host, - port, - client, - }: { - user: string, - password: string, - host: string, - port: number, - client: string, - }) { + static async isMysqlConfigured() { + const { user, password, host, port, client } = TestDbMngr.defaultConnection; const config = NcConfigFactory.urlToDbConfig(`${client}://${user}:${password}@${host}:${port}`); config.connection = { user, @@ -68,13 +51,8 @@ export default class TestDbMngr { return result.code !== -1; } - static async connectMysql({ - user = TestDbMngr.defaultConnection.user, - password = TestDbMngr.defaultConnection.password, - host = TestDbMngr.defaultConnection.host, - port = TestDbMngr.defaultConnection.port, - client = TestDbMngr.defaultConnection.client, - }) { + static async connectMysql() { + const { user, password, host, port, client } = TestDbMngr.defaultConnection; if(!process.env[`DATABASE_URL`]){ process.env[`DATABASE_URL`] = `${client}://${user}:${password}@${host}:${port}/${TestDbMngr.dbName}`; } diff --git a/packages/nocodb/tests/unit/factory/project.ts b/packages/nocodb/tests/unit/factory/project.ts index 09f8b9242c..6e94ca58cc 100644 --- a/packages/nocodb/tests/unit/factory/project.ts +++ b/packages/nocodb/tests/unit/factory/project.ts @@ -49,9 +49,7 @@ const createSakilaProject = async (context) => { .set('xc-auth', context.token) .send(externalProjectConfig); - const project: Project = await Project.getByTitleOrId(response.body.id); - - return project; + return (await Project.getByTitleOrId(response.body.id)) as Project; }; const createProject = async (context, projectArgs = defaultProjectValue) => { @@ -60,8 +58,7 @@ const createProject = async (context, projectArgs = defaultProjectValue) => { .set('xc-auth', context.token) .send(projectArgs); - const project: Project = await Project.getByTitleOrId(response.body.id); - return project; + return (await Project.getByTitleOrId(response.body.id)) as Project; }; export { createProject, createSharedBase, createSakilaProject };