Skip to content

Commit

Permalink
perf(PostgreSQL): improved support of connection strings, closes #893
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio286 committed Nov 8, 2024
1 parent c97ade9 commit f0d312f
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 73 deletions.
8 changes: 0 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@
"node-firebird": "~1.1.8",
"node-loader": "~2.0.0",
"pg": "~8.11.5",
"pg-connection-string": "~2.5.0",
"pg-query-stream": "~4.2.3",
"pgsql-ast-parser": "~7.2.1",
"pinia": "~2.1.7",
Expand Down
1 change: 1 addition & 0 deletions src/common/interfaces/antares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export interface ConnectionParams {
cert?: string;
key?: string;
ca?: string;
connString?: string;
untrustedConnection: boolean;
ciphers?: string;
ssh: boolean;
Expand Down
2 changes: 2 additions & 0 deletions src/main/ipc-handlers/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default (connections: Record<string, antares.Client>) => {
user: conn.user,
password: conn.password,
readonly: conn.readonly,
connectionString: conn.connString,
database: '',
schema: '',
databasePath: '',
Expand Down Expand Up @@ -122,6 +123,7 @@ export default (connections: Record<string, antares.Client>) => {
password: conn.password,
application_name: 'Antares SQL',
readonly: conn.readonly,
connectionString: conn.connString,
database: '',
schema: '',
databasePath: '',
Expand Down
1 change: 1 addition & 0 deletions src/main/libs/clients/PostgreSQLClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export class PostgreSQLClient extends BaseClient {
host: this._params.host,
port: this._params.port,
user: this._params.user,
connectionString: this._params.connectionString,
database: 'postgres' as string,
password: this._params.password,
ssl: null as ConnectionOptions
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/components/WorkspaceAddConnectionPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<div class="column col-7 col-sm-12">
<input
ref="pgString"
v-model="connection.pgConnString"
v-model="connection.connString"
class="form-input"
type="text"
>
Expand Down Expand Up @@ -502,8 +502,8 @@ const connection = ref({
sshKey: '',
sshPort: 22,
sshKeepAliveInterval: 1800,
pgConnString: ''
}) as Ref<ConnectionParams & { pgConnString: string }>;
connString: ''
}) as Ref<ConnectionParams & { connString: string }>;
const firstInput: Ref<HTMLInputElement> = ref(null);
const isConnecting = ref(false);
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/WorkspaceEditConnectionPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<div class="column col-7 col-sm-12">
<input
ref="pgString"
v-model="localConnection.pgConnString"
v-model="localConnection.connString"
class="form-input"
type="text"
>
Expand Down Expand Up @@ -502,7 +502,7 @@ const clients = [
];
const firstInput: Ref<HTMLInputElement> = ref(null);
const localConnection: Ref<ConnectionParams & { pgConnString: string }> = ref(null);
const localConnection: Ref<ConnectionParams & { connString: string }> = ref(null);
const isConnecting = ref(false);
const isTesting = ref(false);
const isAsking = ref(false);
Expand Down
11 changes: 4 additions & 7 deletions src/renderer/ipc-api/Connection.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import { ConnectionParams, IpcResponse } from 'common/interfaces/antares';
import { ipcRenderer } from 'electron';

import connStringConstruct from '../libs/connStringDecode';
import { unproxify } from '../libs/unproxify';

export default class {
static makeTest (params: ConnectionParams & { pgConnString?: string }): Promise<IpcResponse> {
const newParams = connStringConstruct(params) as ConnectionParams;
return ipcRenderer.invoke('test-connection', unproxify(newParams));
static makeTest (params: ConnectionParams & { connString?: string }): Promise<IpcResponse> {
return ipcRenderer.invoke('test-connection', unproxify(params));
}

static connect (params: ConnectionParams & { pgConnString?: string }): Promise<IpcResponse> {
const newParams = connStringConstruct(params) as ConnectionParams;
return ipcRenderer.invoke('connect', unproxify(newParams));
static connect (params: ConnectionParams & { connString?: string }): Promise<IpcResponse> {
return ipcRenderer.invoke('connect', unproxify(params));
}

static abortConnection (uid: string): void {
Expand Down
50 changes: 0 additions & 50 deletions src/renderer/libs/connStringDecode.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/renderer/stores/workspaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export const useWorkspacesStore = defineStore('workspaces', {
else
this.selectedWorkspace = uid;
},
async connectWorkspace (connection: ConnectionParams & { pgConnString?: string }, args?: {mode?: string; signal?: AbortSignal}) {
async connectWorkspace (connection: ConnectionParams & { connString?: string }, args?: {mode?: string; signal?: AbortSignal}) {
this.workspaces = (this.workspaces as Workspace[]).map(workspace => workspace.uid === connection.uid
? {
...workspace,
Expand Down Expand Up @@ -427,7 +427,7 @@ export const useWorkspacesStore = defineStore('workspaces', {

this.selectTab({ uid, tab: 0 });
},
async switchConnection (connection: ConnectionParams & { pgConnString?: string }) {
async switchConnection (connection: ConnectionParams & { connString?: string }) {
await Connection.disconnect(connection.uid);
return this.connectWorkspace(connection, { mode: 'switch' });
},
Expand Down

0 comments on commit f0d312f

Please sign in to comment.