fix(sql): SQL-grid Save parity with Table Browser (schema error, rowid, columnMeta) (#868) - #978
Merged
Merged
Conversation
…d, columnMeta) (Closes #868) The SQL result grid still lagged Table Browser in three ways: - getTableSchema failures were swallowed into 'no primary key': Save silently stayed off and the status looked like a healthy grid. - SQLite tables without a declared primary key could not be saved from a SELECT. - generateMutationPlan received column types but not column meta, so blank generated / default INSERT columns were not omitted. Add SqlResultGridSchema (built from loadTableViewSchema) and use it in the PostgreSQL, MySQL and SQLite SQL workspaces: a schema failure is appended to the status line, SQLite falls back to implicit rowid when the SELECT includes rowid (views are excluded) with a hint when it does not, and column meta is stored on the session and passed into the mutation plan.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Описание изменений
Результат SQL-запроса (SQL workspace) по-прежнему отставал от Table Browser в трёх местах. Общий код вынесен в
SqlResultGridSchema(sql_result_grid_schema.dart), строится из уже существующегоloadTableViewSchema, и подключён в PostgreSQL, MySQL и SQLite workspace.getTableSchemaвcatch (_)превращалась в «нет PK»: Save тихо выключался, а статус выглядел как у здорового грида. Теперь к статусной строке добавляетсяCannot edit: schema unavailable. <ошибка>. Run the query again to retry.rowid(как в Table Browser,sqliteTableBrowserPrimaryKeys). SQL-запрос не переписывается: Save включается, если в SELECT явно естьrowid(SELECT rowid, * FROM t); без него в статусе подсказкаTo edit rows, include rowid in the SELECT…. Для viewrowidне подставляется (тип определяется поsqlite_master). Это второй вариант из issue («документировать необходимость rowid в SELECT»), а не автоматическая подстановка в SQL.resultGridColumnMeta) и передаются вgenerateMutationPlan, так что пустые generated / default / nullable колонки в INSERT пропускаются, как в Table Browser.Тесты
sql_result_grid_schema_test(10 новых): перенос PK, типов и meta, отчёт об ошибке вместо «нет PK», rowid-fallback и подсказка, приоритет объявленного PK, и на реальной SQLite:SELECT rowid, *сохраняется и меняет ровно одну из двух одинаковых строк,SELECT *остаётся read-only с подсказкой, meta позволяет INSERT пропустить пустойid. Прогналtest/features/workspace(весь каталог),test/features/sql_workspacesиtest/core/database, проходят.Не входит
rowidв пользовательский SQL.Связанные Issue
Closes #868