Skip to content

Commit

Permalink
Merge pull request #53 from daimor/master
Browse files Browse the repository at this point in the history
Support for filter
  • Loading branch information
gjsjohnmurray authored Aug 30, 2024
2 parents bb17fe3 + 0aab186 commit f3deda2
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 47 deletions.
53 changes: 18 additions & 35 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
# os: [ubuntu-latest, windows-latest, macOS-latest]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set an output
id: set-version
Expand All @@ -46,18 +46,14 @@ jobs:
echo $VERSION > .version
echo $NAME > .name
- name: Use Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: 14
node-version: 20
- run: npm install
- name: lint
if: runner.os == 'Linux'
run: npm run lint
- run: npm run compile
- name: npm test
uses: GabrielBB/xvfb-action@v1.0
with:
run: npm run test
- name: Build package
if: runner.os == 'Linux'
run: |
Expand All @@ -79,7 +75,7 @@ jobs:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: meta
path: .
Expand All @@ -90,48 +86,35 @@ jobs:
set -x
echo ::set-output name=version::`cat .version`
echo ::set-output name=name::`cat .name`
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: ${{ steps.set-version.outputs.name }}.vsix
- name: Create Release
id: create_release
uses: actions/create-release@v1
if: runner.os == 'Linux'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.set-version.outputs.version }}
release_name: v${{ steps.set-version.outputs.version }}
prerelease: ${{ github.event_name != 'release' }}
body: |
Changes in this release
${{ steps.set-version.outputs.changelog }}
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
uses: softprops/action-gh-release@v2
if: runner.os == 'Linux'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.set-version.outputs.name }}.vsix
asset_name: ${{ steps.set-version.outputs.name }}.vsix
asset_content_type: application/zip
tag_name: v${{ steps.set-version.outputs.version }}
prerelease: ${{ github.event_name != 'release' }}
files: ${{ steps.set-version.outputs.name }}.vsix
token: ${{ secrets.GITHUB_TOKEN }}
publish:
if: github.event_name == 'release'
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
ref: master
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: meta
path: .
- name: Use Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: 14
- name: Prepare build
Expand All @@ -155,15 +138,15 @@ jobs:
npx vsce package -o ${{ steps.set-version.outputs.name }}.vsix
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
uses: softprops/action-gh-release@v2
if: runner.os == 'Linux'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ steps.set-version.outputs.name }}.vsix
asset_name: ${{ steps.set-version.outputs.name }}.vsix
asset_content_type: application/zip
tag_name: v${{ steps.set-version.outputs.version }}
prerelease: ${{ github.event_name != 'release' }}
files: ${{ steps.set-version.outputs.name }}.vsix
token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to VSCode Marketplace
run: |
[ -n "${{ secrets.VSCE_TOKEN }}" ] && \
Expand Down
3 changes: 2 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
"${workspaceFolder}/test/project.code-workspace",
"--extensionDevelopmentPath=${workspaceFolder}"
],
"sourceMaps": true,
"outFiles": [
"${workspaceFolder}/out/**/*.js"
"${workspaceFolder}/dist/**/*.js"
],
"preLaunchTask": "npm: webpack"
}
Expand Down
9 changes: 9 additions & 0 deletions connection.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@
"title": "Show system items?",
"type": "boolean",
"default": false
},
"filter": {
"title": "Filter",
"type": "string",
"examples": [
"'Ens*",
"'HS*"
],
"description": "* 0 or more characters, _ any one character, ' NOT pattern"
}
},
"dependencies": {
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"package": "vsce package -o sqltools-intersystems-driver.vsix",
"lint": ""
"lint": "",
"test": ""
},
"keywords": [
"intersystems-iris-driver",
Expand All @@ -48,7 +49,7 @@
"mtxr.sqltools"
],
"activationEvents": [
"*",
"onStartupFinished",
"onLanguage:sql",
"onCommand:sqltools.*"
],
Expand Down
8 changes: 6 additions & 2 deletions src/ls/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default class IRISDriver extends AbstractDriver<IRISdb, DriverOptions> im

queries: IQueries = queries;
private showSystem = false;
private filter = "";

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

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

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

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

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

switch (item.childType) {
case ContextValue.TABLE:
Expand All @@ -151,11 +155,11 @@ export default class IRISDriver extends AbstractDriver<IRISdb, DriverOptions> im
case ContextValue.DATABASE:
// Syntatically, a schema in IRIS SQL resembles a database in other databases.
// That's the simplest way to adapt IRIS SQL to the generic Hue parser vscode-sqltools uses.
return this.queryResults(this.queries.searchEverything({ search, showSystem: this.showSystem }));
return this.queryResults(this.queries.searchEverything({ search, showSystem: this.showSystem, filter: this.filter }));
case ContextValue.TABLE:
case ContextValue.FUNCTION:
case ContextValue.VIEW:
const searchParams = { search, showSystem: this.showSystem, itemType, ...extraParams };
const searchParams = { search, showSystem: this.showSystem, filter: this.filter, itemType, ...extraParams };
if (extraParams['database']) {
searchParams['schema'] = extraParams['database'];
}
Expand Down
3 changes: 2 additions & 1 deletion src/ls/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ValueColumn[ContextValue.FUNCTION] = "PROCEDURE_NAME";

interface ISchema extends NSDatabase.ISchema {
showSystem: boolean;
filter: string;
}

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

const fetchTableSchemas = fetchTypedSchemas(ContextValue.TABLE);
Expand Down
14 changes: 8 additions & 6 deletions test/project.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,18 @@
"username": "_SYSTEM"
},
{
"askForPassword": false,
"namespace": "USER",
"connectionMethod": "Server and Port",
"showSystem": false,
"filter": "'Ens*",
"previewLimit": 50,
"server": "localhost",
"port": 52773,
"https": false,
"askForPassword": false,
"driver": "InterSystems IRIS",
"name": "InterSystems IRIS",
"namespace": "USER",
"password": "SYS",
"port": 52773,
"previewLimit": 50,
"server": "localhost",
"showSystem": true,
"username": "_SYSTEM"
}
]
Expand Down

0 comments on commit f3deda2

Please sign in to comment.