Skip to content

[Profiler][Doctrine] Runnable query different than actually executed one #40566

Closed
@Wirone

Description

@Wirone

Symfony version(s) affected: 5.2.5

Description
When using query builder with something like:

$qb->andWhere("foo.value IN (:foo_values)");
$qb->setParameter("foo_values", ['bar'], Connection::PARAM_INT_ARRAY);

Doctrine data collector in profiler shows "runnable query" with foo.values IN ('bar') but actually database query contains foo.values IN (0) because of Connection::PARAM_INT_ARRAY param type. It is very misleading, because looking at the profiler you may think the query is correct (even though the result is not).

How to reproduce

  • configure MySQL connection in Doctrine
  • use query builder with IN clause using array of strings as param value and Connection::PARAM_INT_ARRAY as type (which is incorrect)

Possible Solution
Not known.

Additional context
I was struggling with this for long time today because I was getting results that I shouldn't. Looking at Monolog's logs from doctrine channel, then on Doctrine data collector's runnable query - it was all looking good, but unfortunately actual query was different. At the end I checked MySQL's general log and spotted difference in the IN (...) clause. Stupid mistake in query builder, but time wasted mostly because of profiler which was displaying "incorrect" query, different than the executed one.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions