-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Dropped handling of one-based numeric arrays of parameters in Statement::execute() #3809
Dropped handling of one-based numeric arrays of parameters in Statement::execute() #3809
Conversation
5322a4d
to
6911bbc
Compare
@morozov I believe the reason this exists is |
@beberlei yes, this logic might have been introduced in some drivers because it was needed at the time of introduction but it's not currently needed. Additionally, as the test results above show, this behavior is not portable and cannot be relied upon. It works as the test expects only in the drivers that artificially implement this behavior and |
I have to honestly say that I am not to deep to give a good assessment, but the fact that this is not portable across different connections is reason enough to get rid of it. My problem is that this is extremely "hidden" for users in a way that it could lead to sutble breaks if someone would rely on it. |
This is another reason to get rid of this hidden gem in a major release. The change is documented in the upgrade notes and can be elaborated on in greater detail later.
The fact that no one is able to give a good assessment should not be a reason to not proceed with the changes. Otherwise, we'll get stuck maintaining the behavior that no one owns and no one understands forever. This is very unproductive and demotivating. If we merge it like this, as soon as someone comes up with a reason why this change should not have been made, we can reassess it and either revert or provide an alternative solution. |
6911bbc
to
5bff8ec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes also seem to be in sync with the QueryBuilder documentation, where 0 is used for the first parameter. It doesn't though with the Data Retrieval chapter. To prevent the communication of mixed usages, I suggest to adapt the parameter indexes to start with 0: https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/data-retrieval-and-manipulation.html#dynamic-parameters-and-prepared-statements
OCI8/Oracle only supports named parameters, but Doctrine implements a client side parser to allow positional parameters also.
Could this be somehow related to the zero-index decision?
@SenseException, which exactly method do you mean? As pointed out int #3809 (comment),
The former will accept 1-based keys (this did and does work for all DBAL drivers and is true for all underlying drivers that support binding a single parameter natively (PDO, The chapter you're referring to doesn't even mention passing parameters to |
@SenseException if you request changes on a PR, please make sure you can participate in the discussion. This PR is a dependency for #3808 and #3802, so by not replying, you're blocking progress on three issues, not just one. |
5bff8ec
to
d0fe572
Compare
The logic of handling one-based arrays existed in
OCI8Statement
(57a97eb) andSQLSrvStatement
(#110) since their initial implementation without any explanation of why it was needed. Apart from that, the APIs with semantics implicitly defined by input are often more error-prone.This behavior is not portable. Consider the following test:
Currently, it produces the following results:
As you can see, the 2nd test passes only on
sqlsrv
,oci8
(where the logic being removed is explicitly implemented) andmysqli
(which doesn't care about the keys at all because it binds parameters using aforeach
loop).Additionally, the test that covers the logic implemented in
OCI8Statement
currently fails on PHP 8 (#3802) and, if kept, would have to be reworked for #3808.In the past, the test was the source of extra maintenance for no real reason: #3642, #3369, #2854, #3507, #3552.