Browse Source

Fix - SQLite project bug (#1957)

* fix: handle multiple pk and no pk scenarios

re #1956

Signed-off-by: Pranav C <pranavxc@gmail.com>

* refactor: exclude searchpath from db config if client is not pg/mssql

Signed-off-by: Pranav C <pranavxc@gmail.com>

* fix: populate correct knex config for sqlite db

re #1956

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/1965/head
Pranav C 3 years ago committed by GitHub
parent
commit
e0a03963d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      packages/nc-gui/components/createOrEditProject.vue
  2. 6
      packages/nocodb/src/lib/dataMapper/lib/sql/helpers/getAst.ts
  3. 11
      packages/nocodb/src/lib/noco-models/Base.ts

2
packages/nc-gui/components/createOrEditProject.vue

@ -1541,6 +1541,8 @@ export default {
const con = projectJson.envs._noco.db[0]
if (con.client === 'pg' || con.client === 'mssql') {
con.searchPath = [this.schema]
} else if ('searchPath' in con) {
delete con.searchPath
}
const inflection = (con.meta && con.meta.inflection) || {}

6
packages/nocodb/src/lib/dataMapper/lib/sql/helpers/getAst.ts

@ -19,8 +19,10 @@ const getAst = async ({
if (!model.columns?.length) await model.getColumns();
if (extractOnlyPrimaries) {
return {
[model.primaryKey.title]: 1,
[model.primaryValue.title]: 1
...(model.primaryKeys
? model.primaryKeys.reduce((o, pk) => ({ ...o, [pk.title]: 1 }), {})
: {}),
...(model.primaryValue ? { [model.primaryValue.title]: 1 } : {})
};
}

11
packages/nocodb/src/lib/noco-models/Base.ts

@ -108,13 +108,20 @@ export default class Base implements BaseType {
return config;
}
// todo: construct with props
return JSON.parse(
const config = JSON.parse(
CryptoJS.AES.decrypt(
this.config,
Noco.getConfig()?.auth?.jwt?.secret
).toString(CryptoJS.enc.Utf8)
);
// todo: update sql-client args
if (config?.client === 'sqlite3') {
config.connection.filename =
config.connection.filename || config.connection?.connection.filename;
}
return config;
}
getProject(ncMeta = Noco.ncMeta): Promise<Project> {
return Project.get(this.project_id, ncMeta);

Loading…
Cancel
Save