Skip to content

Commit 24f3c8d

Browse files
committed
Support for filter
1 parent 50c52be commit 24f3c8d

File tree

6 files changed

+28
-11
lines changed

6 files changed

+28
-11
lines changed

.vscode/launch.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
"${workspaceFolder}/test/project.code-workspace",
1010
"--extensionDevelopmentPath=${workspaceFolder}"
1111
],
12+
"sourceMaps": true,
1213
"outFiles": [
13-
"${workspaceFolder}/out/**/*.js"
14+
"${workspaceFolder}/dist/**/*.js"
1415
],
1516
"preLaunchTask": "npm: webpack"
1617
}

connection.schema.json

+9
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@
3737
"title": "Show system items?",
3838
"type": "boolean",
3939
"default": false
40+
},
41+
"filter": {
42+
"title": "Filter",
43+
"type": "string",
44+
"examples": [
45+
"'Ens*",
46+
"'HS*"
47+
],
48+
"description": "* 0 or more characters, _ any one character, ' NOT pattern"
4049
}
4150
},
4251
"dependencies": {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"mtxr.sqltools"
4949
],
5050
"activationEvents": [
51-
"*",
51+
"onStartupFinished",
5252
"onLanguage:sql",
5353
"onCommand:sqltools.*"
5454
],

src/ls/driver.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default class IRISDriver extends AbstractDriver<IRISdb, DriverOptions> im
1313

1414
queries: IQueries = queries;
1515
private showSystem = false;
16+
private filter = "";
1617

1718
public async open() {
1819
if (this.connection) {
@@ -22,6 +23,7 @@ export default class IRISDriver extends AbstractDriver<IRISdb, DriverOptions> im
2223
const { namespace } = this.credentials;
2324
let config: IRISDirect;
2425
this.showSystem = this.credentials.showSystem || false;
26+
this.filter = this.credentials.filter || "";
2527

2628
if (this.credentials.serverName) {
2729
throw new Error("not supported");
@@ -113,6 +115,7 @@ export default class IRISDriver extends AbstractDriver<IRISdb, DriverOptions> im
113115

114116
private async getSchemas({ item }: Arg0<IConnectionDriver['getChildrenForItem']>) {
115117
item['showSystem'] = this.showSystem;
118+
item['filter'] = this.filter;
116119

117120
switch (item.childType) {
118121
case ContextValue.TABLE:
@@ -127,6 +130,7 @@ export default class IRISDriver extends AbstractDriver<IRISdb, DriverOptions> im
127130

128131
private async getChildrenForSchema({ item }: Arg0<IConnectionDriver['getChildrenForItem']>) {
129132
item['showSystem'] = this.showSystem;
133+
item['filter'] = this.filter;
130134

131135
switch (item.childType) {
132136
case ContextValue.TABLE:
@@ -151,11 +155,11 @@ export default class IRISDriver extends AbstractDriver<IRISdb, DriverOptions> im
151155
case ContextValue.DATABASE:
152156
// Syntatically, a schema in IRIS SQL resembles a database in other databases.
153157
// That's the simplest way to adapt IRIS SQL to the generic Hue parser vscode-sqltools uses.
154-
return this.queryResults(this.queries.searchEverything({ search, showSystem: this.showSystem }));
158+
return this.queryResults(this.queries.searchEverything({ search, showSystem: this.showSystem, filter: this.filter }));
155159
case ContextValue.TABLE:
156160
case ContextValue.FUNCTION:
157161
case ContextValue.VIEW:
158-
const searchParams = { search, showSystem: this.showSystem, itemType, ...extraParams };
162+
const searchParams = { search, showSystem: this.showSystem, filter: this.filter, itemType, ...extraParams };
159163
if (extraParams['database']) {
160164
searchParams['schema'] = extraParams['database'];
161165
}

src/ls/queries.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ ValueColumn[ContextValue.FUNCTION] = "PROCEDURE_NAME";
1414

1515
interface ISchema extends NSDatabase.ISchema {
1616
showSystem: boolean;
17+
filter: string;
1718
}
1819

1920
const describeTable: IQueries['describeTable'] = queryFactory`
@@ -173,7 +174,7 @@ DISTINCT BY(SCHEMA_NAME)
173174
'${ContextValue.SCHEMA}' as "type",
174175
'${type}' as "childType",
175176
'folder' as iconId
176-
FROM ${Functions[type]} (${p => p.showSystem ? 1 : 0})
177+
FROM ${Functions[type]} (${p => p.showSystem ? 1 : 0}, '${p => (p.filter && p.filter != "") ? `${p.filter.replace("'", "''")}` : "*"}')
177178
`;
178179

179180
const fetchTableSchemas = fetchTypedSchemas(ContextValue.TABLE);

test/project.code-workspace

+8-6
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,18 @@
4242
"username": "_SYSTEM"
4343
},
4444
{
45-
"askForPassword": false,
45+
"namespace": "USER",
4646
"connectionMethod": "Server and Port",
47+
"showSystem": false,
48+
"filter": "'Ens*",
49+
"previewLimit": 50,
50+
"server": "localhost",
51+
"port": 52773,
52+
"https": false,
53+
"askForPassword": false,
4754
"driver": "InterSystems IRIS",
4855
"name": "InterSystems IRIS",
49-
"namespace": "USER",
5056
"password": "SYS",
51-
"port": 52773,
52-
"previewLimit": 50,
53-
"server": "localhost",
54-
"showSystem": true,
5557
"username": "_SYSTEM"
5658
}
5759
]

0 commit comments

Comments
 (0)