-
Notifications
You must be signed in to change notification settings - Fork 511
[CB] SQL Query generation: front-end part #4117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dbeaver/pro#8047-resultset-sql-generation
Are you sure you want to change the base?
[CB] SQL Query generation: front-end part #4117
Conversation
…/pro#8047-create-sql-dialog-for-result-set-frontend
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds the front-end integration for SQL query generation, wiring a new SQL generation dialog into existing UI flows (SQL generators menu + data grid context menu) and introducing supporting SDK/query and utility plumbing.
Changes:
- Add result-set SQL generation support via a new GraphQL query and a
SqlGeneratorsResource.generateResultSetSqlmethod. - Introduce a “Generate SQL” data grid context menu (INSERT/UPDATE/DELETE/SELECT/SELECT IN) that opens the shared generated-SQL dialog.
- Add a
core-utilshelper (executeAsyncSilently) with tests and adopt it in SQL generation entry points.
Reviewed changes
Copilot reviewed 30 out of 31 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| webapp/yarn.lock | Adds workspace dependencies for the new plugin usage and core-utils reference. |
| webapp/packages/plugin-sql-generator/tsconfig.json | Adds core-utils project reference for new imports. |
| webapp/packages/plugin-sql-generator/src/index.ts | Exports GeneratedSqlDialog for reuse by other plugins. |
| webapp/packages/plugin-sql-generator/src/SqlGenerators/SqlGeneratorsResource.ts | Adds generateResultSetSql calling the new SDK query. |
| webapp/packages/plugin-sql-generator/src/SqlGenerators/SqlGeneratorsBootstrap.ts | Switches to prefetching SQL + passing query/exception into the dialog. |
| webapp/packages/plugin-sql-generator/src/SqlGenerators/GeneratedSqlDialog.tsx | Refactors dialog to accept { query, exception, nodeId } payload and removes internal loading/fetch logic. |
| webapp/packages/plugin-sql-generator/package.json | Adds @cloudbeaver/core-utils dependency. |
| webapp/packages/plugin-data-viewer/src/ContainerDataSource.ts | Updates copyright year. |
| webapp/packages/plugin-data-spreadsheet-new/tsconfig.json | Adds project reference to plugin-sql-generator. |
| webapp/packages/plugin-data-spreadsheet-new/src/module.ts | Registers DataGridContextMenuGenerateSqlService. |
| webapp/packages/plugin-data-spreadsheet-new/src/locales/zh.ts | Adds “Generate SQL” menu/dialog/error translations. |
| webapp/packages/plugin-data-spreadsheet-new/src/locales/vi.ts | Adds “Generate SQL” menu/dialog/error translations. |
| webapp/packages/plugin-data-spreadsheet-new/src/locales/ru.ts | Adds “Generate SQL” menu/dialog/error translations. |
| webapp/packages/plugin-data-spreadsheet-new/src/locales/it.ts | Adds “Generate SQL” menu/dialog/error translations. |
| webapp/packages/plugin-data-spreadsheet-new/src/locales/fr.ts | Adds “Generate SQL” menu/dialog/error translations. |
| webapp/packages/plugin-data-spreadsheet-new/src/locales/en.ts | Adds “Generate SQL” menu/dialog/error translations. |
| webapp/packages/plugin-data-spreadsheet-new/src/locales/de.ts | Adds “Generate SQL” menu/dialog/error translations. |
| webapp/packages/plugin-data-spreadsheet-new/src/SpreadsheetBootstrap.ts | Wires DataGridContextMenuGenerateSqlService into bootstrap registration. |
| webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/GenerateSQL/MENU_DATA_GRID_GENERATE_SQL.ts | Introduces the top-level “Generate SQL” context menu. |
| webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuGenerateSqlService.ts | Implements menu/actions handler and invokes result-set SQL generation + dialog opening. |
| webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/Actions/GenerateSQL/ACTION_DATA_GRID_GENERATE_SQL_UPDATE.ts | Adds UPDATE action definition. |
| webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/Actions/GenerateSQL/ACTION_DATA_GRID_GENERATE_SQL_SELECT_MANY.ts | Adds SELECT (IN) action definition. |
| webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/Actions/GenerateSQL/ACTION_DATA_GRID_GENERATE_SQL_SELECT.ts | Adds SELECT action definition. |
| webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/Actions/GenerateSQL/ACTION_DATA_GRID_GENERATE_SQL_INSERT.ts | Adds INSERT action definition. |
| webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/Actions/GenerateSQL/ACTION_DATA_GRID_GENERATE_SQL_DELETE.ts | Adds DELETE action definition. |
| webapp/packages/plugin-data-spreadsheet-new/package.json | Adds dependency on @cloudbeaver/plugin-sql-generator. |
| webapp/packages/plugin-data-import/src/DataImportBootstrap.ts | Updates copyright year. |
| webapp/packages/core-utils/src/index.ts | Exports the new executeAsyncSilently helper. |
| webapp/packages/core-utils/src/executeAsyncSilently.ts | Adds executeAsyncSilently helper for capturing { result, error }. |
| webapp/packages/core-utils/src/executeAsyncSilently.test.ts | Adds Vitest coverage for the new helper. |
| webapp/packages/core-sdk/src/queries/sqlGenerateResultSetQuery.gql | Adds GraphQL query for generating SQL from a result set selection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...ta-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuGenerateSqlService.ts
Outdated
Show resolved
Hide resolved
...ta-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuGenerateSqlService.ts
Outdated
Show resolved
Hide resolved
...ta-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuGenerateSqlService.ts
Outdated
Show resolved
Hide resolved
webapp/packages/plugin-sql-generator/src/SqlGenerators/GeneratedSqlDialog.tsx
Show resolved
Hide resolved
webapp/packages/plugin-sql-generator/src/SqlGenerators/GeneratedSqlDialog.tsx
Outdated
Show resolved
Hide resolved
|
|
||
| return isResultSetDataModel(model) && !model.source.isReadonly(resultIndex); | ||
| }, | ||
| getItems: (context, items) => [...items, MENU_DATA_GRID_GENERATE_SQL], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't we let to generate selects for readony?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cause we decided we don't want this feature for the Grouping panel and Session Manager
We want this feature for: data editor, SQL result sets, and datasets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is hard to understand from code, that model.source.isReadonly(resultIndex) is about excluding Grouping panel and Session Manager
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use helpers such as isDatabaseSessionManagerDataSource that is already exist to exclude specific data sources
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is what we already do:
Line 67 in b180f97
| return isResultSetDataSource(model.source) && !model.isDisabled(resultIndex) && !model.isReadonly(resultIndex); |
...ta-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuGenerateSqlService.ts
Outdated
Show resolved
Hide resolved
...ta-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuGenerateSqlService.ts
Outdated
Show resolved
Hide resolved
…/pro#8047-create-sql-dialog-for-result-set-frontend
...ta-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuGenerateSqlService.ts
Outdated
Show resolved
Hide resolved
...ata-spreadsheet-new/src/DataGrid/Actions/GenerateSQL/ACTION_DATA_GRID_GENERATE_SQL_DELETE.ts
Outdated
Show resolved
Hide resolved
|
|
||
| return isResultSetDataModel(model) && !model.source.isReadonly(resultIndex); | ||
| }, | ||
| getItems: (context, items) => [...items, MENU_DATA_GRID_GENERATE_SQL], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is hard to understand from code, that model.source.isReadonly(resultIndex) is about excluding Grouping panel and Session Manager
...ta-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuGenerateSqlService.ts
Outdated
Show resolved
Hide resolved
| isActionApplicable: (context, action) => | ||
| [ | ||
| ACTION_DATA_GRID_GENERATE_SQL_INSERT, | ||
| ACTION_DATA_GRID_GENERATE_SQL_UPDATE, | ||
| ACTION_DATA_GRID_GENERATE_SQL_DELETE, | ||
| ACTION_DATA_GRID_GENERATE_SQL_SELECT, | ||
| ACTION_DATA_GRID_GENERATE_SQL_SELECT_MANY, | ||
| ].includes(action), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just specify:
actions: [
ACTION_DATA_GRID_GENERATE_SQL_INSERT,
ACTION_DATA_GRID_GENERATE_SQL_UPDATE,
ACTION_DATA_GRID_GENERATE_SQL_DELETE,
ACTION_DATA_GRID_GENERATE_SQL_SELECT,
ACTION_DATA_GRID_GENERATE_SQL_SELECT_MANY,
]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the main purpose of the IAction is to provide additional behaviour such as shortcuts or reusability in different contexts, IAction is some of kind standarterized action in the application that can be used in different contexts (menus, menu bars), you don't need to create action for every item in the menu, sometimes it's more convenient to use MenuBaseItem
...ta-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuGenerateSqlService.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 40 out of 41 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...ta-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuGenerateSqlService.ts
Show resolved
Hide resolved
…/pro#8047-create-sql-dialog-for-result-set-frontend
…/pro#8047-create-sql-dialog-for-result-set-frontend
closes https://github.com/dbeaver/pro/issues/8048