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

[Parser] Combination of discriminator, WhereInWalker, cloneQuery and apostrophe in like query causes parameters to not be bound #11567

Open
fliespl opened this issue Aug 8, 2024 · 2 comments

Comments

@fliespl
Copy link

fliespl commented Aug 8, 2024

Bug Report

Q A
Version 3.8.4, 3.8.7

Summary

My summary is not gonna be precise, that's why I have prepared a repro in github.

Basically using combination of mentioned above items, we can get into situation where parser mistakenly thinks it must not fill parameters (or skips some of them).

I have narrowed it down to regexp which searches query for parameters that it misses one of them in such conditions.

Current behaviour

Some parameters are not added due to parser missing resolution of one of the parameters due to apostrophe.

SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens

How to reproduce

Created symfony app (https://github.com/fliespl/doctrine-error) with minimal repo. Consists of two commands:

php bin/console sample:good - this one goes through since parameter has no apostrophe.
php bin/console sample:error - this one fails due to apostrophe.

Expected behaviour

I would expect parser to correctly handled escaped literal strings with apostrophe.

@derrabus derrabus transferred this issue from doctrine/dbal Aug 8, 2024
@greg0ire
Copy link
Member

The reproducer does not work for me:

$ bin/console -vvv

In ConfigureDependencyFactoryPass.php line 27:

  [RuntimeException]
  DoctrineMigrationsBundle requires DoctrineBundle to be enabled.


Exception trace:
  at /tmp/doctrine-error/vendor/doctrine/doctrine-migrations-bundle/DependencyInjection/CompilerPass/ConfigureDependencyFactoryPass.php:27
 Doctrine\Bundle\MigrationsBundle\DependencyInjection\CompilerPass\ConfigureDependencyFactoryPass->process() at /tmp/doctrine-error/vendor/symfony/dependency-injection/Compiler/Compiler.php:73
 Symfony\Component\DependencyInjection\Compiler\Compiler->compile() at /tmp/doctrine-error/vendor/symfony/dependency-injection/ContainerBuilder.php:752
 Symfony\Component\DependencyInjection\ContainerBuilder->compile() at /tmp/doctrine-error/vendor/symfony/http-kernel/Kernel.php:495
 Symfony\Component\HttpKernel\Kernel->initializeContainer() at /tmp/doctrine-error/vendor/symfony/http-kernel/Kernel.php:740
 Symfony\Component\HttpKernel\Kernel->preBoot() at /tmp/doctrine-error/vendor/symfony/http-kernel/Kernel.php:120
 Symfony\Component\HttpKernel\Kernel->boot() at /tmp/doctrine-error/vendor/symfony/framework-bundle/Console/Application.php:177
 Symfony\Bundle\FrameworkBundle\Console\Application->registerCommands() at /tmp/doctrine-error/vendor/symfony/framework-bundle/Console/Application.php:69
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /tmp/doctrine-error/vendor/symfony/console/Application.php:167
 Symfony\Component\Console\Application->run() at /tmp/doctrine-error/vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:49
 Symfony\Component\Runtime\Runner\Symfony\ConsoleApplicationRunner->run() at /tmp/doctrine-error/vendor/autoload_runtime.php:29
 require_once() at /tmp/doctrine-error/bin/console:15

@fliespl
Copy link
Author

fliespl commented Aug 10, 2024

@greg0ire sorry about that - 3 files were left uncommited. Fixed in repo

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

No branches or pull requests

2 participants