Skip to content

Commit 82392d5

Browse files
Merge pull request #62 from gjsjohnmurray/fix-4
Add `resultSetRowLimit` extension setting
2 parents c71739d + c82436d commit 82392d5

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

package.json

+13
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,19 @@
5353
"onLanguage:sql",
5454
"onCommand:sqltools.*"
5555
],
56+
"contributes": {
57+
"configuration": {
58+
"title": "SQLTools InterSystems IRIS Driver",
59+
"properties": {
60+
"sqltools-intersystems-driver.resultSetRowLimit": {
61+
"description": "Maximum number of rows returned by any query, including metadata queries. Use 0 for no limit, which may cause timeouts or other failures. Setting is applied at connection time and is ignored by server versions earlier than 2023.1.",
62+
"type": "integer",
63+
"default": 1000,
64+
"minimum": 0
65+
}
66+
}
67+
}
68+
},
5669
"main": "./dist/extension.js",
5770
"ls": "./dist/ls/plugin.js",
5871
"dependencies": {

src/extension.ts

+2
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ export async function activate(extContext: ExtensionContext): Promise<IDriverExt
149149
await resolvePassword(connSpec);
150150
resolvedConnSpecs.set(serverName, connSpec);
151151
}
152+
const resultSetRowLimit = vscode.workspace.getConfiguration('sqltools-intersystems-driver').get('resultSetRowLimit');
152153
connInfo = { ...connInfo,
153154
https: connSpec.webServer.scheme === 'https',
154155
server: connSpec.webServer.host,
@@ -157,6 +158,7 @@ export async function activate(extContext: ExtensionContext): Promise<IDriverExt
157158
username: connSpec.username,
158159
password: connSpec.password,
159160
namespace,
161+
resultSetRowLimit,
160162
}
161163
}
162164
return connInfo;

src/ls/driver.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default class IRISDriver extends AbstractDriver<IRISdb, DriverOptions> im
1515
queries: IQueries = queries;
1616
private showSystem = false;
1717
private filter = "";
18+
private resultSetRowLimit;
1819

1920
public async open() {
2021
if (this.connection) {
@@ -26,7 +27,7 @@ export default class IRISDriver extends AbstractDriver<IRISdb, DriverOptions> im
2627
this.showSystem = this.credentials.showSystem || false;
2728
this.filter = this.credentials.filter || "";
2829

29-
let { https, server: host, port, pathPrefix, username, password } = this.credentials;
30+
let { https, server: host, port, pathPrefix, username, password, resultSetRowLimit } = this.credentials;
3031
config = {
3132
https,
3233
host,
@@ -36,8 +37,9 @@ export default class IRISDriver extends AbstractDriver<IRISdb, DriverOptions> im
3637
username,
3738
password
3839
};
40+
this.resultSetRowLimit = resultSetRowLimit;
3941

40-
const irisdb = new IRISdb(config);
42+
const irisdb = new IRISdb(config, resultSetRowLimit);
4143
return irisdb.open()
4244
.then(() => {
4345
this.connection = Promise.resolve(irisdb);
@@ -91,7 +93,7 @@ export default class IRISDriver extends AbstractDriver<IRISdb, DriverOptions> im
9193
resultsAgg.push({
9294
cols,
9395
connId: this.getId(),
94-
messages: [{ date: new Date(), message: `Query ok with ${queryResult[0]?.content.length ?? 'no'} results` }],
96+
messages: [{ date: new Date(), message: `Query ok with ${queryResult[0]?.content.length ?? 'no'} results (resultSetRowLimit = ${this.resultSetRowLimit})` }],
9597
results: this.mapRows(queryResult[0]?.content, cols),
9698
query: queries.toString(),
9799
requestId: opt.requestId,

src/ls/irisdb.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,18 @@ export interface IQueries extends IBaseQueries {
2626
export default class IRISdb {
2727

2828
private config: IRISDirect;
29+
private resultSetRowLimit: number;
2930
private cookies: string[] = [];
3031
private _apiVersion = 1;
3132

3233
public get apiVersion() {
3334
return this._apiVersion;
3435
}
3536

36-
public constructor(config: IRISDirect) {
37+
public constructor(config: IRISDirect, resultSetRowLimit: number) {
3738
this.config = config;
3839
this.config.namespace = this.config.namespace.toUpperCase();
40+
this.resultSetRowLimit = resultSetRowLimit;
3941
}
4042

4143
public updateCookies(newCookies: string[]): void {
@@ -187,7 +189,7 @@ export default class IRISdb {
187189
return this.request(1, "POST", `${this.config.namespace}/action/query`, {
188190
parameters,
189191
query,
190-
}, this._apiVersion >= 6 ? { positional: true } : {}).then(data => data.result)
192+
}, this._apiVersion >= 6 ? { positional: true , max: this.resultSetRowLimit > 0 ? this.resultSetRowLimit : undefined } : {}).then(data => data.result)
191193
}
192194

193195

0 commit comments

Comments
 (0)