more flexible connection dialog, improved UX when connecting to redshift

This commit is contained in:
Jan Prochazka
2021-05-16 11:22:48 +02:00
parent 6d7cc7d441
commit 8bffa4a7dd
10 changed files with 201 additions and 102 deletions

View File

@@ -97,16 +97,38 @@ const drivers = driverBases.map(driverBase => ({
...driverBase,
analyserClass: Analyser,
async connect({ server, port, user, password, database, ssl }) {
const client = new pg.Client({
// connectionString: 'postgres://root@localhost:26257/postgres?sslmode=disabke'
host: server,
port,
user,
password,
database: database || 'postgres',
ssl,
});
async connect({ engine, server, port, user, password, database, databaseUrl, ssl }) {
let options = null;
if (engine == 'redshift@dbgate-plugin-postgres') {
let url = databaseUrl;
if (url && url.startsWith('jdbc:redshift://')) {
url = url.substring('jdbc:redshift://'.length);
}
if (user && password) {
url = `postgres://${user}:${password}@${url}`;
} else if (user) {
url = `postgres://${user}@${url}`;
} else {
url = `postgres://${url}`;
}
options = {
connectionString: url,
};
} else {
options = {
// connectionString: 'postgres://root@localhost:26257/postgres?sslmode=disabke'
host: server,
port,
user,
password,
database: database || 'postgres',
ssl,
};
}
const client = new pg.Client(options);
await client.connect();
return client;
},