Replace built-in multi query parser with nextras/multi-query-parser#151
Merged
Replace built-in multi query parser with nextras/multi-query-parser#151
Conversation
16426f8 to
aeddb9e
Compare
There was a problem hiding this comment.
Pull request overview
This pull request refactors the SQL parsing logic by replacing a hand-rolled 75-line SQL parser with the external nextras/multi-query-parser library. The change simplifies the codebase by delegating complex SQL parsing logic to a dedicated library that handles MySQL and PostgreSQL syntax differences, including features like DELIMITER statements, dollar-quoted strings, and comment handling.
Changes:
- Adds
nextras/multi-query-parser(v2.0) as a dependency - Introduces abstract
createMultiQueryParser()method inBaseDriver, implemented byMySqlDriverandPgSqlDriverwith their respective parser classes - Simplifies
BaseDriver::loadFile()from 75 lines to ~13 lines by delegating to the library'sparseFile()method - Updates unit tests to mock the new parser method and adjusts expected query values to reflect the library's behavior of trimming leading whitespace/comments
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| composer.json | Adds nextras/multi-query-parser version ^2.0 as a required dependency |
| src/Drivers/BaseDriver.php | Removes hand-rolled parser, adds abstract createMultiQueryParser() method, simplifies loadFile() to use library's parser |
| src/Drivers/MySqlDriver.php | Implements createMultiQueryParser() returning MySqlMultiQueryParser instance |
| src/Drivers/PgSqlDriver.php | Implements createMultiQueryParser() returning PostgreSqlMultiQueryParser instance |
| tests/cases/unit/BaseDriverTest.phpt | Updates test mocking to use MySqlMultiQueryParser, adjusts expected values for trimmed whitespace, removes duplicate test case |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ibrary The hand-rolled SQL parser in BaseDriver::loadFile() is replaced by the dedicated nextras/multi-query-parser package, which provides proper database-specific parsers (MySQL, PostgreSQL) with streaming support.
aeddb9e to
922bdeb
Compare
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
nextras/multi-query-parseras a dependencyBaseDriver::loadFile()with calls toIMultiQueryParser::parseFile()createMultiQueryParser()toBaseDriver, implemented byMySqlDriver(→MySqlMultiQueryParser) andPgSqlDriver(→PostgreSqlMultiQueryParser)Test plan