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

Problems when Escaping LIKE-Statements in Oracle #3379

Closed
fleckiboy opened this issue Dec 4, 2018 · 4 comments
Closed

Problems when Escaping LIKE-Statements in Oracle #3379

fleckiboy opened this issue Dec 4, 2018 · 4 comments

Comments

@fleckiboy
Copy link

I'm currently facing the following Error.

When running the following code, i get an Error 'ORA-01008: Not all Variables bound'.
The problem are the 2 Escape-Statements in my LIKE-Clauses. If i have just one of these, or none, the statement works perfectly. But everytime i'm using more than one LIKE-ESCAPE clauses, i'm getting the error.

$sql = "SELECT * FROM table WHERE col1 LIKE :p1 ESCAPE '\' OR col2 LIKE :p2 ESCAPE '\'";
$params = array('p1' => '%\_%', 'p2' => 'test');
/** EntityManager $em */
$em->getConnection()->fetchAssoc($sql, $params);

I'm currently running Doctrine\DBAL in version 2.5.4.

@Ocramius
Copy link
Member

Ocramius commented Dec 4, 2018

Please verify on latest DBAL first.

@morozov
Copy link
Member

morozov commented Dec 6, 2018

This should be a duplicate of #3371.

@morozov
Copy link
Member

morozov commented Oct 30, 2021

This must have been fixed by #4397, no longer reproducible on 3.1.x. In the ANSI mode, the query in question is parsed as:

SELECT * FROM table WHERE col1 LIKE {:p1} ESCAPE '\' OR col2 LIKE {:p2} ESCAPE '\'

The curly braces identify what has been recognized as a parameter (see Doctrine\DBAL\Tests\SQL\ParserTest#testAnsiEscaping()).

@morozov morozov closed this as completed Oct 30, 2021
@morozov morozov added this to the 3.0.0 milestone Oct 30, 2021
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants