doctrine / orm

Doctrine Object Relational Mapper (ORM)
https://www.doctrine-project.org/projects/orm.html
MIT License
9.94k stars 2.52k forks source link

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

Open fliespl opened 3 months ago

fliespl commented 3 months ago

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.

greg0ire commented 3 months ago

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 commented 3 months ago

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