mirror of
https://github.com/morluto/rea.git
synced 2026-11-29 01:46:39 +00:00
* fix(sqlite): accept the documented sqlite_master spelling of the schema catalog
SQLite's schema-table documentation, "Alternative Names", recognizes four spellings and says
plainly that `sqlite_master` "works anywhere" while the two `sqlite_temp_*` forms only resolve for
the TEMP database. The inspector accepted exactly one of them.
`table: "sqlite_master"` was refused with "Selected ordinary table does not exist with that exact
name: sqlite_master", which is factually wrong for a name the engine resolves:
| same library, same connection | result |
| --- | --- |
| `SELECT count(*) FROM sqlite_master` | 1 |
| `SELECT count(*) FROM sqlite_schema` | 1 |
| `SELECT count(*) FROM pragma_table_list WHERE name = 'sqlite_master'` | **0** |
| `pragma_table_xinfo('sqlite_master', 'main')` | `type, name, tbl_name, rootpage, sql` |
The stored-catalog identity comes from `temp.pragma_table_list` with a `COLLATE BINARY` exact-name
match, and that inventory lists the catalog under its canonical spelling only, so the alias never
reached the row-source facts that already work. All three schema scopes threw.
Both spellings now yield the same rows and order, and the catalog still publishes no invented
declaration:
| spelling | before | after |
| --- | --- | --- |
| `sqlite_schema` | rows, `order: rowid` | unchanged |
| `sqlite_master` | THREW | rows, `order: rowid`, no self-declaration |
| `sqlite_temp_schema`, `sqlite_temp_master`, `SQLITE_MASTER` | THREW | still THREW |
| `absent` | THREW | still THREW |
Only the everywhere-alias is added. The TEMP-only spellings and a case variant stay refused,
because SQLite does not resolve them here either.
The guide now names both spellings instead of promising one exact name.
`tests/boundary/sqlite` and `src/application/sqlite` — 79 passing, 1 skipped, 6 new cases.
Reverting the normalization fails three of them.
* test(sqlite): cover the alias through the service boundary
A review finding on the previous commit: the shared predicate change also alters
`SqliteDatabaseService.matchesSelectedSchema`, which decides CLI and MCP result admission, and
nothing exercised the alias there.
The alias case now runs through the service twice — once against a report whose catalog carries no
self-declaration, which must be admitted, and once against a report that declares the table, which
must stay an output error. Dropping the alias from `sqliteSchemaHasObjectDeclaration` fails it.
* refactor(sqlite): derive the catalog declaration check from its spelling owner
---------
Co-authored-by: 吴佳浩 <wujiahao@supremind.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>