Skip to content

fix(Database): escape table identifiers in SQLite3 foreign_key_list PRAGMA - #10732

Merged
paulbalandan merged 2 commits into
codeigniter4:developfrom
gr8man:fix/sqlite3-foreign-key-data-table-escape
Nov 14, 2026
Merged

paulbalandan merged 2 commits into
codeigniter4:developfrom
gr8man:fix/sqlite3-foreign-key-data-table-escape

Conversation

@gr8man

@gr8man gr8man commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Description
SQLite3\Connection::_foreignKeyData() interpolated $table directly into PRAGMA foreign_key_list({$table}) without identifier escaping or attached database prefix handling. This caused syntax errors on table names containing hyphens, spaces, reserved SQL words, or attached schemas (e.g. schema.table). Identifiers are now escaped and schema prefixes are handled outside parentheses.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@carson-codeigniter4 carson-codeigniter4 Bot added the bug Verified issues on the current code behavior or pull requests that will fix them label Nov 5, 2026
Comment thread system/Database/SQLite3/Connection.php Resolved
@gr8man
gr8man force-pushed the fix/sqlite3-foreign-key-data-table-escape branch from 881993c to 7da8053 Compare November 12, 2026 10:31
Comment thread system/Database/SQLite3/Connection.php Resolved
@gr8man
gr8man force-pushed the fix/sqlite3-foreign-key-data-table-escape branch from 7da8053 to ce306ec Compare November 12, 2026 13:18

@neznaika0 neznaika0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DROP TABLE IF EXISTS ..
It’s optional, the tables have already been created. Well, okay then.

@gr8man
gr8man force-pushed the fix/sqlite3-foreign-key-data-table-escape branch from 88d5a19 to ea156e8 Compare November 12, 2026 21:54
@gr8man
gr8man force-pushed the fix/sqlite3-foreign-key-data-table-escape branch from ea156e8 to f5a0778 Compare November 13, 2026 10:15
@paulbalandan
paulbalandan merged commit 9601f2d into codeigniter4:develop Nov 14, 2026
59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Verified issues on the current code behavior or pull requests that will fix them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants