Skip to content

Commit 47f37cc

Browse files
authored
Update connection schema (#634)
* remove useHTTPS option * update port setting * remove obsolete version string * fix connection schems, use uri format for server * update ovsx * remove todo * remove limit * empty pass by default * update changelog
1 parent 9c58ba8 commit 47f37cc

File tree

9 files changed

+44
-172
lines changed

9 files changed

+44
-172
lines changed

.devcontainer/docker-compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: "3.8"
2-
31
services:
42
app:
53
build:

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313

1414
### Changed
1515

16+
- Updated connection schema, `Server` now in `uri` format. That's mean you need
17+
to specify protocol (#634).
18+
- Removed `useHTTPS` option. If you need a `HTTPS` connection,
19+
specify it in server, e.g. `https://node01.clickhouse.cloud`.
1620
- Updated dependencies.
1721

1822
## [0.6.0] - 2024-08-03

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,3 @@ For more details see SQLTools [documentation](https://vscode-sqltools.mteixeira.
2828
and statistics.
2929
- Don't send multiple queries, this is not supported
3030
by SQLTools (yet).
31-
- Use `LIMIT` when selecting a large amount of data, otherwise the results may
32-
take a long time to load.

connection.schema.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"server": {
3535
"title": "Server",
3636
"type": "string",
37-
"default": "localhost",
37+
"format": "uri",
38+
"default": "http://localhost",
3839
"minLength": 1
3940
},
4041
"port": {
@@ -61,18 +62,13 @@
6162
"Use empty password",
6263
"Save as plaintext in settings"
6364
],
64-
"default": "SQLTools Driver Credentials"
65+
"default": "Use empty password"
6566
},
6667
"requestTimeout": {
6768
"title": "Request timeout in milliseconds",
6869
"type": "integer",
6970
"default": 30000
7071
},
71-
"useHTTPS": {
72-
"title": "Use HTTPS",
73-
"type": "boolean",
74-
"default": false
75-
},
7672
"enableTls": {
7773
"type": "boolean",
7874
"title": "Enable TLS",

package-lock.json

Lines changed: 13 additions & 155 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
"concurrently": "^9.0.1",
101101
"cross-env": "^7.0.3",
102102
"esbuild": "^0.24.0",
103-
"ovsx": "^0.9.4",
103+
"ovsx": "^0.9.5",
104104
"rimraf": "^6.0.1",
105105
"typescript": "^5.6.2"
106106
}

src/extension.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ export async function activate(
6262
parseBeforeSaveConnection: ({ connInfo }) => {
6363
const propsToRemove = ["passwordMode"];
6464

65+
if (
66+
!connInfo.server.startsWith("http://") &&
67+
!connInfo.server.startsWith("https://")
68+
) {
69+
connInfo.server = "http://" + connInfo.server;
70+
}
71+
6572
if (connInfo.passwordMode) {
6673
if (connInfo.passwordMode.toString().toLowerCase().includes("ask")) {
6774
connInfo.askForPassword = true;
@@ -92,6 +99,13 @@ export async function activate(
9299
...connInfo,
93100
};
94101

102+
if (
103+
!connInfo.server.startsWith("http://") &&
104+
!connInfo.server.startsWith("https://")
105+
) {
106+
formData.server = "http://" + connInfo.server;
107+
}
108+
95109
if (connInfo.askForPassword) {
96110
formData.passwordMode = "Ask on connect";
97111
delete formData.password;

src/ls/driver.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,22 @@ export default class ClickHouseDriver
5050
}
5151
: undefined;
5252

53+
let server = this.credentials.server;
54+
if (!server.startsWith("http://") && !server.startsWith("https://")) {
55+
server = "http://" + server;
56+
}
57+
58+
const url = new URL(server);
59+
url.port = this.credentials.port.toString();
60+
5361
const opts = {
54-
url: `${this.credentials.useHTTPS ? "https" : "http"}://${
55-
this.credentials.server
56-
}:${this.credentials.port}`,
62+
url: url,
5763
username: this.credentials.username,
5864
password: this.credentials.password,
5965
request_timeout: this.credentials.requestTimeout,
6066
application: "sqltools-clickhouse-driver",
6167
database: this.credentials.database,
6268
tls: tlsConfig,
63-
// TODO: check clickhouse_settings.default_format: "JSON"
6469
} as ClickHouseClientConfigOptions;
6570

6671
this.connection = Promise.resolve(createClient(opts));

ui.schema.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"passwordMode",
88
"password",
99
"requestTimeout",
10-
"useHTTPS",
1110
"enableTls",
1211
"tls"
1312
],

0 commit comments

Comments
 (0)