Browse Source

fix(gui-v2): add mariadb mysql mapping and add test for DATABASE_URL

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3528/head
Pranav C 2 years ago
parent
commit
def45f99d8
  1. 29
      packages/nocodb/src/__tests__/noco/NcConfigFactory.test.ts
  2. 1
      packages/nocodb/src/lib/utils/NcConfigFactory.ts

29
packages/nocodb/src/__tests__/noco/NcConfigFactory.test.ts

@ -38,6 +38,35 @@ describe('Config Factory Tests', () => {
expect(dbConfig).to.deep.equal(rest);
done();
});
it('Generate config from DATABASE_URL', function (done) {
// postgres url
const ncDbUrl = NcConfigFactory.extractXcUrlFromJdbc(
'postgres://username:password@host:5432/db'
);
expect(ncDbUrl).to.be.equal('pg://host:5432?u=username&p=password&d=db&');
// postgres url without port
const ncDbUrl1 = NcConfigFactory.extractXcUrlFromJdbc(
'postgres://username:password@host/db'
);
expect(ncDbUrl1).to.be.equal('pg://host:5432?u=username&p=password&d=db&');
// mysql url
const ncDbUrl2 = NcConfigFactory.extractXcUrlFromJdbc(
'jdbc:mysql://localhost/sample_db'
);
expect(ncDbUrl2).to.be.equal('mysql2://localhost:3306?d=sample_db&');
// mariadb url
const ncDbUrl3 = NcConfigFactory.extractXcUrlFromJdbc(
'jdbc:mariadb://localhost/sample_db'
);
expect(ncDbUrl3).to.be.equal('mysql2://localhost:3306?d=sample_db&');
done();
});
it('Connection string with nested property', function (done) {
const dbConfig = NcConfigFactory.metaUrlToDbConfig(
`pg://localhost:5432?u=postgres&p=xgene&d=abcde&pool.min=1&pool.max=2&ssl.rejectUnauthorized=false`

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

@ -20,6 +20,7 @@ const {
const driverClientMapping = {
mysql: 'mysql2',
mariadb: 'mysql2',
postgres: 'pg',
postgresql: 'pg',
sqlite: 'sqlite3',

Loading…
Cancel
Save