mtxr / vscode-sqltools

Database management for VSCode
https://vscode-sqltools.mteixeira.dev?utm_source=github&utm_medium=homepage-link
MIT License
1.44k stars 291 forks source link

changing tabs when running multiple queries throws error #988

Closed bangroot closed 1 year ago

bangroot commented 1 year ago

When I run multiple queries in a @block against postgres, if I try to change tabs in the output window, I get the following error:

Error: The columnWidths property of the TableColumnResizing plugin is given an invalid value.

    in GetterBase
    in Unknown
    in Unknown
    in PluginIndexer
    in PluginBase
    in Unknown
    in Unknown
    in Unknown
    in PluginIndexer
    in PluginBase
    in Unknown
    in Unknown
    in GridCore
    in PluginIndexer
    in PluginHostBase
    in Unknown
    in Grid
    in div
    in ForwardRef
    in ForwardRef
    in Unknown
    in Unknown
    in div
    in Unknown
    in Unknown
    in Unknown
    in ErrorBoundary
    in ThemeProvider_ThemeProvider
    in Unknown

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

gjsjohnmurray commented 1 year ago

Cross-referenced to https://github.com/mtxr/vscode-sqltools/issues/920#issuecomment-1241439519

leonid-shevtsov commented 1 year ago

Also happens if you set "sqltools.results.reuseTabs": "connection" and run a new query.

Seems like it has to do with the number of columns in the result set; if it changes you get the error.

gjsjohnmurray commented 1 year ago

@leonid-shevtsov thanks for the clue.

@mtxr I can repro it in the test workspace by creating the contacts table and then running this pair of queries together:

SELECT first_name FROM contacts;
SELECT first_name, last_name FROM contacts;

The result tab appears with two sub-tabs. When I switch to the second sub-tab the error gets reported there.

Initially I couldn't get breakpoints in .tsx files to bind. I fixed that by adding this to the "Launch SQLTools" configuration in launch.json

"debugWebviews": true,

The error no longer happens after I comment out this code:

https://github.com/mtxr/vscode-sqltools/blob/17de7a5c8047a1df7013228d2aad96cbea4aa9a0/packages/plugins/connection-manager/webview/ui/screens/Results/components/Table/index.tsx#L204-L206

But then after I switch to the second sub-tab and resize one of the columns the crash occurs.

I don't know enough about the TSX stuff that's used for this webview, so I haven't been able to get any further. But it feels like something is getting called to manipulate two columns before the previous one-column table has been replaced by the new two-column table.

gjsjohnmurray commented 1 year ago

Different numbers of columns don't seem to be required. I also get it from this:

select 1 from contacts;
select 2 from contacts;

But not from this:

select 1 from contacts;
select 2 as '1' from contacts;
yevon commented 1 year ago

Same here with Postgresql. If you check the reuse tab setting, it just fails when changing the query.

gjsjohnmurray commented 1 year ago

@mtxr when you have some time please investigate this issue.

gjsjohnmurray commented 1 year ago

Version 0.27.0 should resolve this.