Browse Source

Merge pull request #4609 from nocodb/fix/sqlite-warning

fix: add useNullAsDefault flag for sqlite on root level
pull/4614/head
աɨռɢӄաօռɢ 2 years ago committed by GitHub
parent
commit
cda1ebd3fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      packages/nocodb/src/lib/db/sql-client/lib/sqlite/SqliteClient.ts
  2. 5
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/CustomKnex.ts
  3. 1
      packages/nocodb/src/lib/meta/MetaAPILogger.ts
  4. 4
      packages/nocodb/src/lib/meta/NcMetaIOImpl.ts
  5. 1
      packages/nocodb/src/lib/meta/api/projectApis.ts
  6. 2
      packages/nocodb/src/lib/utils/NcConfigFactory.ts

2
packages/nocodb/src/lib/db/sql-client/lib/sqlite/SqliteClient.ts

@ -19,6 +19,8 @@ class SqliteClient extends KnexClient {
private _version: any; private _version: any;
constructor(connectionConfig) { constructor(connectionConfig) {
// sqlite does not support inserting default values and knex fires a warning without this flag
connectionConfig.connection.useNullAsDefault = true;
super(connectionConfig); super(connectionConfig);
this.sqlClient = knex(connectionConfig.connection); this.sqlClient = knex(connectionConfig.connection);
this.queries = queries; this.queries = queries;

5
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/CustomKnex.ts

@ -988,6 +988,11 @@ function parseNestedCondition(obj, qb, pKey?, table?, tableAlias?) {
type CustomKnex = Knex; type CustomKnex = Knex;
function CustomKnex(arg: string | Knex.Config<any> | any): CustomKnex { function CustomKnex(arg: string | Knex.Config<any> | any): CustomKnex {
// sqlite does not support inserting default values and knex fires a warning without this flag
if (arg?.client === 'sqlite3') {
arg.useNullAsDefault = true;
}
const kn: any = knex(arg); const kn: any = knex(arg);
const knexRaw = kn.raw; const knexRaw = kn.raw;

1
packages/nocodb/src/lib/meta/MetaAPILogger.ts

@ -11,7 +11,6 @@ export default class MetaAPILogger {
connection: { connection: {
filename: 'noco_log.db', filename: 'noco_log.db',
}, },
useNullAsDefault: true,
}); });
} }

4
packages/nocodb/src/lib/meta/NcMetaIOImpl.ts

@ -77,10 +77,6 @@ export default class NcMetaIOImpl extends NcMetaIO {
constructor(app: Noco, config: NcConfig, trx = null) { constructor(app: Noco, config: NcConfig, trx = null) {
super(app, config); super(app, config);
if (this.config?.meta?.db?.client === 'sqlite3') {
this.config.meta.db.useNullAsDefault = true;
}
if (this.config?.meta?.db) { if (this.config?.meta?.db) {
this.connection = trx || XKnex(this.config?.meta?.db); this.connection = trx || XKnex(this.config?.meta?.db);
} else { } else {

1
packages/nocodb/src/lib/meta/api/projectApis.ts

@ -138,7 +138,6 @@ async function projectCreate(req: Request<any, any>, res) {
connection: { connection: {
filename: `${toolDir}/nc_minimal_dbs/${projectTitle}_${dbId}.db`, filename: `${toolDir}/nc_minimal_dbs/${projectTitle}_${dbId}.db`,
}, },
useNullAsDefault: true,
}, },
}, },
inflection_column: 'camelize', inflection_column: 'camelize',

2
packages/nocodb/src/lib/utils/NcConfigFactory.ts

@ -200,7 +200,6 @@ export default class NcConfigFactory implements NcConfig {
}, },
database: database:
url.searchParams.get('d') || url.searchParams.get('database'), url.searchParams.get('d') || url.searchParams.get('database'),
useNullAsDefault: true,
}, },
} as any; } as any;
} else { } else {
@ -496,7 +495,6 @@ export default class NcConfigFactory implements NcConfig {
connection: { connection: {
...dbConnectionConfig, ...dbConnectionConfig,
database: dbConnectionConfig.connection.filename, database: dbConnectionConfig.connection.filename,
useNullAsDefault: true,
}, },
}; };
} }

Loading…
Cancel
Save