Skip to content

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 <[email protected]>
Signed-off-by: Matthew Peveler <[email protected]>
'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
@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.

3 participants