-
-
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
Fix breaks named parameters in Oracle #3738
Conversation
@eisberg could you also add a test? |
021f8d8
to
091095b
Compare
c7a6fd7
to
cefd2dd
Compare
1e6f514
to
8312053
Compare
tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php
Outdated
Show resolved
Hide resolved
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.
The
testQueryConversion
test does not cover all use cases because it calls theexecuteQuery
method on theconnection
object. In this case, the named parameters are transformed into positional ones.
Thanks for bringing this up. We probably need to get rid of this behavior since, on the one hand, it doesn't make any sense for the drivers that support named parameters but don't support the positional ones. On the other hand, it's a driver-specific logic implemented on the wrapper level.
We'll try to take care of that in a different issue. Besides a few nitpicks, looks good.
tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php
Outdated
Show resolved
Hide resolved
$param = $this->_paramMap[$param]; | ||
if (is_int($param)) { | ||
if (! isset($this->_paramMap[$param])) { | ||
throw new OCI8Exception(sprintf('Could not find variable mapping with index %d, in the SQL statement', $param)); |
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.
The idea behind throwing an exception is that in this case, it wouldn't have worked previously anyways, so we're just making the error more explicit. Need to double-check that before merging.
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.
any news?
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.
@eisberg I forgot about it. Thank you for the reminder.
This is a valid code example that works on 2.9
and a build from this PR:
$stmt = $conn->prepare('SELECT :p FROM DUAL');
$stmt->bindValue('p', 'foo');
$stmt->execute();
echo $stmt->fetchColumn(), PHP_EOL;
// foo
This is an example of invalid code that is not supposed to work:
$stmt = $conn->prepare('SELECT :p FROM DUAL');
$stmt->bindValue(1, 'foo');
$stmt->execute();
echo $stmt->fetchColumn(), PHP_EOL;
On 2.9
it produces:
Warning: oci_bind_by_name(): ORA-01036: illegal variable name/number in lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php on line 287
Uncaught Doctrine\DBAL\Driver\OCI8\OCI8Exception: ORA-01008: not all variables bound
On a build from this patch it produces:
Uncaught Doctrine\DBAL\Driver\OCI8\OCI8Exception: Could not find variable mapping with index 1, in the SQL statement
Which is perfectly fine. DBAL prevents a knowingly invalid operation on the underlying driver.
@eisberg please rebase your patch onto |
71b852d
to
9f4d9a5
Compare
Thank you @eisberg! |
Fixes #3722
Closes #3779
Summary
Fix breaks named parameters in Oracle ( see issue #3722 )