orm icon indicating copy to clipboard operation
orm copied to clipboard

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

Open fliespl opened this issue 1 year ago • 2 comments

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.

fliespl avatar Aug 08 '24 13:08 fliespl

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

greg0ire avatar Aug 10 '24 08:08 greg0ire

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

fliespl avatar Aug 10 '24 09:08 fliespl