dbgate icon indicating copy to clipboard operation
dbgate copied to clipboard

Db2-Plugin

Open GergesBernaba1 opened this issue 7 months ago • 33 comments

  • Added getStructureFixed.js to provide an enhanced implementation of the getStructure method for the DB2 driver, including error handling and a fallback to a basic implementation.
  • Updated sql.js to exclude system schemas from schema retrieval.
  • Enhanced driver.js with improved column properties and schema handling configurations.
  • Modified test-db2-driver.js to use environment variables for database connection details.
  • Introduced test-network-debug.js for debugging network requests and testing API endpoints directly.

GergesBernaba1 avatar May 27 '25 19:05 GergesBernaba1

I am testing this plugin with local DB2 instance, there are lot of errors in console and I see no tables in table view.

How did you configure connection to DB2?

I use following settings:

image

janproch avatar May 30 '25 08:05 janproch

I use the database URL in the DB2 connection for a database directly, and all data is retrieved successfully, and the UI shows correct DB2

GergesBernaba1 avatar May 30 '25 09:05 GergesBernaba1

Could you please share your database URL, of course without sensitive data?

We have no experience with DB2 (I and nobody of my colleagues), so we are struggling with this a bit

Ideally, also a screenshot of connection settings with erased sensitive data

Thank yout

janproch avatar May 30 '25 10:05 janproch

Please check this screenshot for the connection string

image

GergesBernaba1 avatar May 30 '25 11:05 GergesBernaba1

this after add new rows image

GergesBernaba1 avatar May 30 '25 11:05 GergesBernaba1

Great thanks, I am connected now!

Sometimes it shows correct structure, sometimes not...

Probably problem is in method incrementalAnalysis in Analyser ? If this method will be deleted, it will behave better

We have to do more test, but basically it seems to work

As your plugin has GPL license, I have to ask you, whether it is OK for you to be shipped with commercial DbGate Premium? Of course, it will be also part of opensource Community

We have lot of tests for each DB engine (approx. 100), I could merge DB2 plugin into DbGate, but with - "Experimental" status, until all these tests will be implmeneted - passed or marked as skip

Thank you

janproch avatar May 30 '25 12:05 janproch

Also, when you choose "All schemas", the are 8 of procedures without name

image

This must be returned from Analyser class

janproch avatar May 30 '25 12:05 janproch

Thanks for the update! I'll investigate the incremental incrementalAnalysis of the issue and the bug where eight procedures lack names under "All schemas." I'm happy to help with testing to stabilize the plugin.

I'm fine with the GPL-licensed plugin being included in both DbGate Community and Premium editions. Please let me know if any licensing details need discussion.

Labeling the plugin "experimental" until tests are complete makes sense. I can assist with test implementation or debugging. Let me know the next steps!

GergesBernaba1 avatar May 30 '25 13:05 GergesBernaba1

Hi Jan,

I've addressed the issue in a new pull request (#1135). Could you please review it when you have a moment? If everything looks good, I'd recommend merging this new PR instead of the previous one.

image

GergesBernaba1 avatar Jun 01 '25 10:06 GergesBernaba1

Hi @janproch i hope you are doing well! Did you check it?

GergesBernaba1 avatar Jun 06 '25 11:06 GergesBernaba1

Hi @GergesBernaba1 ,

yes I did, thank you I am now a bit stucked with new release, which is planned to June 16, but I want to merge your new PR into this release, so that DB2 support will be part of this (also with upcoming Firebird support) I believe that we will have capacity to merge and test this next week

Thank you

janproch avatar Jun 06 '25 12:06 janproch

I’d be glad to contribute more to this project. Do you have a task list I can help with? Feel free to assign me any items.

GergesBernaba1 avatar Jun 06 '25 14:06 GergesBernaba1

Thanks for the offer. There is lot of unsolved issue for DbGate - https://github.com/dbgate/dbgate/issues

If you choose something, better to let me know, some issues are already in progress

Thanks

BTW. I have merged your newer DB2 PR into new feature branch - feature/db2, I will run some tests in this branch and then merge it into master - PR https://github.com/dbgate/dbgate/issues

janproch avatar Jun 09 '25 13:06 janproch

No good news, we have three times red https://github.com/dbgate/dbgate/actions/runs/15536757630 ... I tried to update electron (https://www.npmjs.com/package/ibm_db claims that it supports electron 32-35), but yet without success

janproch avatar Jun 09 '25 15:06 janproch

@janproch, Are you trying to update the Electron version to: 32.1.0!

GergesBernaba1 avatar Jun 09 '25 15:06 GergesBernaba1

Could run the action again!

GergesBernaba1 avatar Jun 09 '25 16:06 GergesBernaba1

I tried change version - 32.1.0, the same error - https://github.com/dbgate/dbgate/actions/runs/15577442183/job/43864975613

Build process is building native img_db package, but it should use precompiled version, probably precompiled version is not found

Probably right electron version with precompiled packages should solve this. But unfortunately, I have no capacity to solve this before current release, so probably we have to postpone adding DB2 to next release

janproch avatar Jun 11 '25 06:06 janproch

image It works fine, check the screenshot.

GergesBernaba1 avatar Jun 13 '25 11:06 GergesBernaba1

Hi @janproch Are you trying it again? In my local machine, on Windows, the app is working without any errors

GergesBernaba1 avatar Jun 20 '25 19:06 GergesBernaba1

On my PC it also worked correctly in local development.

But we need to correctly build it on github pipelines, this is a bit more complicated, because imb_db package uses native JS module, which brings problems always. This job could not be easily delegated any of my colleagues, so it must wait, until there are no urgencies from Premium users and from DbGate investor

janproch avatar Jun 23 '25 12:06 janproch

Hi @GergesBernaba1 ,

thanks for patience

There is apparantly problem with installing this package in electron, docker build works correctly - https://github.com/dbgate/dbgate/actions/runs/16340367906 , but electron build fails when installing packages - https://github.com/dbgate/dbgate/actions/runs/16340367905

I replicated this problem on my local computer with Windows OS, using commands:

node adjustPackageJson.js
cd app
yarn install

According to documentation, there should be precompiled packages, for electron, but they are not used

Electron Binaries - From electron v32 to v35. Hence, no support for vscode older than v1.95.

janproch avatar Jul 17 '25 09:07 janproch

@GergesBernaba1 It worked locally for you even under electron ?

Did you install packages for electron? ( yarn install in "app" subdirectory)

janproch avatar Jul 17 '25 09:07 janproch

yes i did

GergesBernaba1 avatar Jul 17 '25 13:07 GergesBernaba1

If it works for you, could you please send me console log, when adding ibm_db package to electron app?

cd app
yarn add ibm_db

I ended with following error, I would like to know, whether your install process used precompiled package for electron:

yarn add v1.22.19
[1/4] Resolving packages...
warning ibm_db > [email protected]: You or someone you depend on is using Q, the JavaScript Promise library that gave JavaScript developers strong feelings about promises. They can almost certainly migrate to the native JavaScript promise now. Thank you literally everyone for joining me in this bet against the odds. Be excellent to each other.

(For a CapTP with native promises, see @endo/eventual-send and @endo/captp)
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "electron-builder > [email protected]" has unmet peer dependency "[email protected]".
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 35 new dependencies.
info Direct dependencies
└─ [email protected]
info All dependencies
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
└─ [email protected]
$ yarn rebuild && patch-package
yarn run v1.22.19
$ electron-builder install-app-deps
  • electron-builder  version=25.1.8
  • loaded configuration  file=package.json ("build" field)
  • executing @electron/rebuild  electronVersion=30.0.2 arch=x64 buildFromSource=false appDir=./
  • installing native dependencies  arch=x64
  • preparing       moduleName=ibm_db arch=x64
  ⨯ (node:31536) [DEP0060] DeprecationWarning: The `util._extend` API is deprecated. Please use Object.assign() instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Error: Could not find any Visual Studio installation to use
    at VisualStudioFinder.fail (C:\jenasoft\dbgate-merged\app\node_modules\node-gyp\lib\find-visualstudio.js:122:47)
    at C:\jenasoft\dbgate-merged\app\node_modules\node-gyp\lib\find-visualstudio.js:75:16
    at VisualStudioFinder.findVisualStudio2013 (C:\jenasoft\dbgate-merged\app\node_modules\node-gyp\lib\find-visualstudio.js:380:14)
    at C:\jenasoft\dbgate-merged\app\node_modules\node-gyp\lib\find-visualstudio.js:71:14
    at VisualStudioFinder.findVisualStudio2015 (C:\jenasoft\dbgate-merged\app\node_modules\node-gyp\lib\find-visualstudio.js:364:14)
    at C:\jenasoft\dbgate-merged\app\node_modules\node-gyp\lib\find-visualstudio.js:67:12
    at failPowershell (C:\jenasoft\dbgate-merged\app\node_modules\node-gyp\lib\find-visualstudio.js:156:7)
    at VisualStudioFinder.parseData (C:\jenasoft\dbgate-merged\app\node_modules\node-gyp\lib\find-visualstudio.js:170:14)
    at C:\jenasoft\dbgate-merged\app\node_modules\node-gyp\lib\find-visualstudio.js:143:14
    at ChildProcess.exithandler (node:child_process:407:7)
    at ChildProcess.emit (node:events:518:28)
    at maybeClose (node:internal/child_process:1101:16)
    at ChildProcess._handle.onexit (node:internal/child_process:304:5)


  ⨯ node-gyp failed to rebuild 'C:\jenasoft\dbgate-merged\app\node_modules\ibm_db'  failedTask=installAppDeps stackTrace=Error: node-gyp failed to rebuild 'C:\jenasoft\dbgate-merged\app\node_modules\ibm_db'
    at ChildProcess.<anonymous> (C:\jenasoft\dbgate-merged\app\node_modules\@electron\rebuild\lib\module-type\node-gyp\node-gyp.js:121:24)
    at ChildProcess.emit (node:events:518:28)
    at ChildProcess._handle.onexit (node:internal/child_process:293:12)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

janproch avatar Jul 18 '25 07:07 janproch

yarn add ibm_db yarn add v1.22.22 warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json. [1/4] Resolving packages... [2/4] Fetching packages... [3/4] Linking dependencies... warning "electron-builder > [email protected]" has unmet peer dependency "[email protected]". [4/4] Building fresh packages... success Saved 1 new dependency. info Direct dependencies └─ [email protected] info All dependencies └─ [email protected] $ yarn rebuild && patch-package yarn run v1.22.22 $ electron-builder install-app-deps • electron-builder version=25.1.8 • loaded configuration file=package.json ("build" field) • executing @electron/rebuild electronVersion=22.3.27 arch=x64 buildFromSource=false appDir=./ • installing native dependencies arch=x64 • preparing moduleName=ibm_db arch=x64 • finished moduleName=ibm_db arch=x64 • preparing moduleName=odbc arch=x64 • finished moduleName=odbc arch=x64 • completed installing native dependencies Done in 7.20s. patch-package 6.5.1 Applying patches... No patch files found Done in 91.04s.

GergesBernaba1 avatar Jul 18 '25 14:07 GergesBernaba1

i have to set this before run it: $env:IBM_DB_HOME="{current Loction for app}\dbgate\app\node_modules\ibm_db\installer\clidriver"

and add those if not in the package JSON file: "ibm_db": "^3.3.2", "odbc": "^2.4.9",

And in the main, in the same file: "@electron/rebuild": "^3.2.10", "node-gyp": "^11.2.0" "electron": "22.3.27", and downgrade the electron version, or pull the latest

GergesBernaba1 avatar Jul 18 '25 14:07 GergesBernaba1

@janproch are you checking it?

GergesBernaba1 avatar Jul 30 '25 10:07 GergesBernaba1

I am trying to upgrade to newest stable electron 37 now, I hope it will help solve issues like this

janproch avatar Jul 30 '25 11:07 janproch

@janproch Are you still waiting for any modifications from me?

GergesBernaba1 avatar Nov 02 '25 10:11 GergesBernaba1

@GergesBernaba1 plugin is OK, the problem is with the DB2 native NPM package, which breaks electron app installation. I have no idea how to solve this, probably big upgrade of all dependencies could help, but for this big upgrade we have curreclty no free capacity

janproch avatar Nov 03 '25 07:11 janproch