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

Connection::quote() can only quote strings #3488

Merged
merged 3 commits into from
Mar 16, 2019

Conversation

morozov
Copy link
Member

@morozov morozov commented Mar 16, 2019

Q A
Type improvement
BC Break yes

The signature of Connection::quote() allows mixed $input and int $type. On the one hand, not all drivers support all existing types, on the other hand, from the SQL perspective, it doesn't make any sense to quote anything else than a string.

As part of the mixed type, the method accepts null but implicitly converts it to a string which is unacceptable in the SQL context. Enforcing the accepted type to string helped reveal a few bugs (to be reported later, see the test failures).

The wrapper connection also supports DBAL types which in the absence of the sense in driver-level types in the escaping context boils down to just converting the value to a PHP value which may not even be a string. Besides being redundant, this functionality doesn't have any test coverage.

It's proposed to keep Connection::quote() responsible only for quoting strings.

@Ocramius
Copy link
Member

Patch looks good, but CI is still unhappy with it

1. The argument is always available since the method is only called from listTableIndexes() which requires a table name.
2. The argument itself seems a workaround and only needed to bypass the fact that the SQLiteSchemaManager violates the method contract: instead of reformatting the provided data it fetches more data from the DB schema which requires a table name. This argument should be dropped completely later.
@morozov
Copy link
Member Author

morozov commented Mar 16, 2019

Patch looks good, but CI is still unhappy with it

I thought it was due to some implementations of AbstractPlatform::getListViewsSQL(), ::getListSequencesSQL() and ::getListTableForeignKeysSQL() not properly handling $database = null and was planning to report/address them separately as a dependency for this issue. However, it turned out the failures weren't because of that.

Those issues are still to be reported and address later.

@morozov morozov requested a review from Ocramius March 16, 2019 18:51
@Ocramius Ocramius self-assigned this Mar 16, 2019
@Ocramius Ocramius added this to the 3.0.0 milestone Mar 16, 2019
Copy link
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

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

👍 🚢

@Ocramius Ocramius merged commit de019a4 into doctrine:develop Mar 16, 2019
@morozov morozov deleted the quote-only-string branch March 16, 2019 19:41
morozov pushed a commit that referenced this pull request Mar 18, 2019
Connection::quote() can only quote strings
morozov pushed a commit that referenced this pull request Apr 16, 2019
Connection::quote() can only quote strings
morozov pushed a commit that referenced this pull request May 6, 2019
Connection::quote() can only quote strings
morozov pushed a commit that referenced this pull request May 23, 2019
Connection::quote() can only quote strings
morozov pushed a commit to morozov/dbal that referenced this pull request May 31, 2019
Connection::quote() can only quote strings
morozov pushed a commit that referenced this pull request Jun 13, 2019
Connection::quote() can only quote strings
morozov pushed a commit that referenced this pull request Jun 27, 2019
Connection::quote() can only quote strings
morozov pushed a commit that referenced this pull request Jun 27, 2019
Connection::quote() can only quote strings
morozov pushed a commit that referenced this pull request Jun 27, 2019
Connection::quote() can only quote strings
morozov pushed a commit to morozov/dbal that referenced this pull request Aug 26, 2019
Connection::quote() can only quote strings
morozov pushed a commit that referenced this pull request Nov 2, 2019
Connection::quote() can only quote strings
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants