Repository navigation
Store the database name in the database field for ALTER and DROP DATABASE - #692
Open
kamil-tekiela wants to merge 1 commit into
Open
kamil-tekiela wants to merge 1 commit into
kamil-tekiela wants to merge 1 commit into
Conversation
…BASE AlterStatement and DropStatement parsed the name of a database as a table name, so `ALTER DATABASE db` and `DROP DATABASE db` had the name in `$expr->table`. Query::getTables() also listed the database of `ALTER DATABASE db` as a table. Parse the name with `parseField => database` when the statement has the DATABASE or SCHEMA option, as CreateStatement already does. For DROP, the generic Statement::parse() looked up the clause parser options before the statement options were known; Statement now gets them from the new getKeywordParserOptions() method, which DropStatement overrides. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #692 +/- ##
============================================
+ Coverage 96.79% 96.82% +0.02%
- Complexity 2252 2258 +6
============================================
Files 90 91 +1
Lines 4966 4973 +7
============================================
+ Hits 4807 4815 +8
+ Misses 159 158 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
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.
AlterStatementandDropStatementparse the name of a database as a table name:ALTER DATABASE db ...$stmt->table->table = 'db'$stmt->table->database = 'db'DROP DATABASE db/DROP SCHEMA db$stmt->fields[0]->table = 'db'$stmt->fields[0]->database = 'db'CreateStatementalready usesparseField => databaseforCREATE DATABASE/SCHEMA, so the three statements were inconsistent.Query::getTables()also returned the database ofALTER DATABASE dbas a table; it now returns[].Changes
AlterStatement::parse()parses the name intodatabasewhen theDATABASEoption is set.Statement::parse()looked up the clause parser options before it parsed the statement options. It now gets them, after the statement options, from the newprotected getKeywordParserOptions().DropStatementoverrides it forDATABASE/SCHEMA.DROP DATABASE a.bnow reports "Unexpected dot.", the same asCREATE DATABASE a.b.Compatibility
Code that reads the database name from
->tableof these statements must read->databaseinstead. phpMyAdmin does this inTracker::parseQuery(), so I targetmasterand not a patch branch.🤖 Generated with Claude Code