Skip to content

Problem in $this->em->createNativeQuery #55

Open
@aurelienpiquet

Description

@aurelienpiquet

Hello,

Here is the bug i have:

"detail": "An exception occurred while executing 'SELECT * FROM faq WHERE id IN (c06cf73a-e4a8-11ec-b466-0242ac120004, c06caf90-e4a8-11ec-b466-0242ac120004) ORDER BY FIELD(id,c06cf73a-e4a8-11ec-b466-0242ac120004, c06caf90-e4a8-11ec-b466-0242ac120004)':\n\nSQLSTATE[42S22]: Column not found: 1054 Unknown column 'c06cf73a' in 'where clause'",

The SQL query doesn't have '' arround the ids, so it returns this error. If i run this query manualy with the '' arround the ids, it works fine.

It seems to work fine if i change the CollectionFinder.php to :

        for ($i = 0; $i < count($ids); $i++) {
            if ($i === count($ids) -1) {
                $sentence .= "'" . $ids[$i] . "'";
            } else {
                $sentence .= "'" . $ids[$i] . "',";
            }
        }
         $query           = $this->em->createNativeQuery('SELECT * FROM '.$tableName.' WHERE '.$primaryKeyInfos['entityAttribute'].'   IN ('. $sentence . ') ORDER BY FIELD(id,'. $sentence .')', $rsm);

Here is my composer.json :
"php": "8.0.",
"ext-ctype": "
",
"ext-gd": "",
"ext-iconv": "
",
"acseo/typesense-bundle": "^0.6.7",
"beberlei/doctrineextensions": "^1.3",
"doctrine/annotations": "^1.0",
"doctrine/dbal": "^2.10",
"doctrine/doctrine-bundle": "^2.5",
"doctrine/doctrine-migrations-bundle": "^3.2",
"doctrine/orm": "^2.11",
"phpstan/phpdoc-parser": "^1.2",
"phpstan/phpstan-doctrine": "^1.2",
"phpstan/phpstan-symfony": "^1.1",
"symfony/asset": "5.4.",
"symfony/console": "5.4.
",
"symfony/dotenv": "5.4.",
"symfony/expression-language": "5.4.
",
"symfony/flex": "^1.17|^2",
"symfony/form": "5.4.",
"symfony/framework-bundle": "5.4.
",
"symfony/htatp-client": "5.4.",
"symfony/intl": "5.4.
",
"symfony/mailer": "5.4.",
"symfony/messenger": "5.4.
",
"symfony/mime": "5.4.",
"symfony/monolog-bundle": "^3.0",
"symfony/notifier": "5.4.
",
"symfony/process": "5.4.",
"symfony/property-access": "5.4.
",
"symfony/property-info": "5.4.",
"symfony/proxy-manager-bridge": "5.4.
",
"symfony/runtime": "5.4.",
"symfony/security-bundle": "5.4.
",
"symfony/sendgrid-mailer": "5.3.",
"symfony/serializer": "5.4.
",
"symfony/string": "5.4.",
"symfony/templating": "5.4.
",
"symfony/translation": "5.4.",
"symfony/twig-bundle": "5.4.
",
"symfony/uid": "5.4.",
"symfony/validator": "5.4.
",
"symfony/web-link": "5.4.",
"symfony/webapp-meta": "^1.0",
"symfony/webpack-encore-bundle": "^1.12",
"symfony/yaml": "5.4.
",

Can this parse error comes from my configs?

Regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions