Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix quoting DB name when creating/dropping #2286

Merged
merged 1 commit into from
Jun 4, 2024

Conversation

MasterOdin
Copy link
Member

@MasterOdin MasterOdin commented Jun 4, 2024

Port of cakephp/migrations#717 to phinx which fixed using values that needed being escaped for mysql, but did not fix it for postgres or sqlserver.

I think there is still issues in some other places the DB name can be referenced in being quoted, but they're used within WHERE clauses within a SQL statement, and the fix there is to rework the queries to be parameterized vs using sprintf, which can be done in a follow-up PR.

Co-authored-by: jharder <jared.harder@gmail.com>
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
'CREATE DATABASE `%s` DEFAULT CHARACTER SET `%s` COLLATE `%s`',
$name,
'CREATE DATABASE %s DEFAULT CHARACTER SET `%s` COLLATE `%s`',
$this->quoteColumnName($name),
Copy link
Member Author

Choose a reason for hiding this comment

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

The upstream patch used $this->quoteTableName which does an escape around any . characters in addition to calling quoteColumnName where it's assuming that it's a separator between schema and table name. Given that database names don't have schema references, better I think to use quoteColumnName directly.

@dereuromark dereuromark merged commit b1e128c into 0.x Jun 4, 2024
11 of 12 checks passed
@dereuromark dereuromark deleted the fix-database-escaped-characters branch June 4, 2024 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants