Repository navigation
feat(translate): emulate information_schema FK reflection views (CakePHP 5) - #61
Merged
Merged
Conversation
Emulate information_schema.key_column_usage, referential_constraints, table_constraints (primary + foreign keys) and check_constraints (always empty). Foreign keys are derived from pragma_foreign_key_list and named <table>_ibfk_<n>, matching MySQL's unnamed-InnoDB-key convention. Fold constraint_schema and referenced_table_schema comparisons like table_schema so a bound schema name matches litewire's main schema. CakePHP 5 reads these views when it describes a table (describeForeignKeySql, describeCheckConstraints) and failed with 1064 before.
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.
CakePHP 5's schema reflection (
describeForeignKeySql/describeCheckConstraints) queriesinformation_schema.key_column_usage,referential_constraints,table_constraintsandcheck_constraints. litewire didn't emulate them, so every table describe returned 1064 and the app 500'd.What this adds
Four more emulated
information_schemaviews, in the same derived-table style as the existingtables/columns/statistics/schemataemulation:key_column_usage— one row per foreign-key column, all 12 MySQL columns. Derived frompragma_foreign_key_list; primary/unique columns are not listed. An implicitREFERENCES tresolves to the parent's key column.referential_constraints— one row per FK, all 11 MySQL columns (incl.UPDATE_RULE/DELETE_RULE).table_constraints— primary keys and foreign keys (UNIQUE/CHECK not listed).check_constraints— always empty; SQLite keeps CHECK clauses only inside the CREATE text.Unnamed SQLite FKs are named
<table>_ibfk_<n>, matching MySQL's unnamed-InnoDB-key convention.constraint_schemaandreferenced_table_schemanow fold liketable_schema, so a bound schema name matches litewire'smain.Integer columns are
CAST(... AS INTEGER): on Turso a prepared select of an integer expression through a derived table drops the connection unless the expression carries a declared type.Tests
New
mysql_infoschema_fkruns both CakePHP queries verbatim as prepared statements over the wire on rusqlite and Turso, plus plainSELECT *column-name checks, the empty case, FK rules (CASCADE/SET NULL), composite FKs, andtable_constraints. clippy--all-targets -D warningsand nightly fmt are clean. (single_tenant_attach_keeps_working_over_the_wirefails identically on untouched main — a pre-existing Windows path issue.)Verified end-to-end against the consolidated wun image: CakePHP's describe no longer 1064s and
GET /api/productsis byte-identical to the oracle.