Fix SQL Table - #477
Open
andrewdalpino wants to merge 3 commits into
Open
Conversation
andrewdalpino
commented
Sep 7, 2026
Member
- Removed $connection->quote($table) (produced a string literal like 'pets' in FROM → MySQL ERROR 1149)
- Added strict identifier whitelist: /^[A-Za-z_][A-Za-z0-9_](.[A-Za-z_][A-Za-z0-9_])?$/ → throws InvalidArgumentException otherwise (src/Extractors/SQLTable.php:64-66)
- Query changed to portable LIMIT {$batchSize} OFFSET :offset (valid on MySQL, SQLite, PostgreSQL), replacing the MySQL/SQLite-only LIMIT :offset, N (src/Extractors/SQLTable.php:95)
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
It introduces typed class constants (protected const string ...) which will cause a parse error on the repo’s supported PHP versions (composer.json declares PHP >=7.4).
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates the SQLTable extractor to fix invalid table name quoting, add table-identifier validation to prevent SQL injection via the table parameter, and make pagination syntax portable across MySQL/SQLite/PostgreSQL.
Changes:
- Added a strict identifier whitelist for table names and throw
InvalidArgumentExceptionfor invalid identifiers. - Removed use of
PDO::quote()for the table name and now interpolate the validated identifier directly. - Updated the query pagination from
LIMIT :offset, NtoLIMIT N OFFSET :offset, and added a unit test covering invalid identifiers.
File summaries
| File | Description |
|---|---|
| src/Extractors/SQLTable.php | Removes value-quoting of table names, adds identifier validation, and switches to portable LIMIT ... OFFSET ... syntax. |
| tests/Extractors/SQLTableTest.php | Adds a test ensuring invalid table identifiers are rejected via InvalidArgumentException. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.