Conversation
Implement SqliteMultiQueryParser with support for all three SQLite identifier quoting styles (double quotes, backticks, brackets), single-quoted strings with doubled-quote escaping, non-nesting block comments, and BEGIN...END compound statements for CREATE TRIGGER while correctly treating BEGIN TRANSACTION as a simple statement.
There was a problem hiding this comment.
Pull request overview
This pull request adds a new SqliteMultiQueryParser class to parse SQLite SQL scripts that may contain multiple queries. The implementation correctly handles SQLite's dialect features including three identifier quoting styles (double quotes, backticks, and brackets), single-quoted strings with escaped quotes using doubled characters, non-nesting block comments, and compound BEGIN...END statements for triggers.
Changes:
- Added
SqliteMultiQueryParserclass with comprehensive regex patterns for parsing SQLite-specific SQL syntax - Included test data file with 62 diverse queries covering tables, views, triggers, and various identifier quoting styles
- Comprehensive test suite with 247 lines covering edge cases, chunk boundary safety, and randomized chunking scenarios
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/SqliteMultiQueryParser.php | New parser implementation extending BaseMultiQueryParser with SQLite-specific regex patterns for handling identifiers, strings, comments, and BEGIN...END blocks |
| tests/cases/SqliteMultiQueryParserTest.phpt | Comprehensive test suite with 72 tests covering superfluous semicolons, edge cases (identifiers, strings, comments, BEGIN variants), and chunk boundary scenarios |
| tests/data/sqlite.sql | Test data file with 62 queries including CREATE TABLE/VIEW/TRIGGER/INDEX statements, PRAGMA, INSERT, DELETE, and SELECT queries demonstrating all SQLite identifier quoting styles and edge cases |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Factor out inner construct bodies (sqI, dqI, btI, bkI, bcI) and reusable sub-patterns (skip, stmt, lc) into a DEFINE block, replacing the $simpleQuery string concatenation hack with a single self-contained pattern. (*PRUNE) remains inline at the call sites because PCRE confines backtracking verbs to subroutine scope.
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.
Summary
SqliteMultiQueryParsersupporting all SQLite-specific SQL dialect features: three identifier quoting styles (double quotes, backticks, brackets), single-quoted strings with doubled-quote escaping, and non-nesting block commentsBEGIN...ENDcompound statements (forCREATE TRIGGER) while correctly treatingBEGIN TRANSACTION/DEFERRED/IMMEDIATE/EXCLUSIVEand bareBEGIN;as simple statementsTest plan
composer run phpstanpasses with no errorscomposer run testspasses all 72 tests including exhaustive two-chunk combinations and randomized chunking