Discriminator column empty value "IN" query #7186

Closed
opened 2026-01-22 15:46:19 +01:00 by admin · 4 comments
Owner

Originally created by @Legion112 on GitHub (Jul 17, 2023).

Bug Report

Q A
BC Break no
Version 2.14.2

Summary

DiscriminatorMap adding empty value ('') to SQL query example:

Executing query: SELECT o0_.id AS id_0, o0_.amount AS amount_1, o0_.depositAddress AS depositAddress_2, o0_.name AS name_3, o0_.network AS network_4, o0_.type AS type_5 FROM operations o0_ WHERE o0_.type IN ('blockchain-in', 'expense', '')

This leads to error invalid input value when using Enum for Postgres DB

Current behavior

Adding o0_.type IN ('blockchain-in', 'expense', '') is incorrect and should be o0_.type IN ('blockchain-in', 'expense')

How to reproduce

I create a repository with an easy way to reproduce this issue.
It was introduced in version 2.14.2 prior to this version it was working as expected.

You could verify it by cloning the repository: https://github.com/Legion112/doctrine-playground
After cloning use docker for quick setup:

make shell 

After running the command below in logs you could see a wrong select statement

composer require doctrine/orm:2.14.2 -W && php index.php

I have confirmed that this version correctly was formatted correctly

Expected behavior

Executing query: SELECT o0_.id AS id_0, o0_.amount AS amount_1, o0_.depositAddress AS depositAddress_2, o0_.name AS name_3, o0_.network AS network_4, o0_.type AS type_5 FROM operations o0_ WHERE o0_.type IN ('blockchain-in', 'expense')
Originally created by @Legion112 on GitHub (Jul 17, 2023). ### Bug Report <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ------ | BC Break | no | Version | 2.14.2 #### Summary DiscriminatorMap adding empty value (`''`) to SQL query example: ``` Executing query: SELECT o0_.id AS id_0, o0_.amount AS amount_1, o0_.depositAddress AS depositAddress_2, o0_.name AS name_3, o0_.network AS network_4, o0_.type AS type_5 FROM operations o0_ WHERE o0_.type IN ('blockchain-in', 'expense', '') ``` This leads to error `invalid input value` when using Enum for Postgres DB <!-- Provide a summary describing the problem you are experiencing. --> #### Current behavior Adding `o0_.type IN ('blockchain-in', 'expense', '')` is incorrect and should be `o0_.type IN ('blockchain-in', 'expense')` <!-- What is the current (buggy) behavior? --> #### How to reproduce <!-- Provide steps to reproduce the bug. If possible, also add a code snippet with relevant configuration, entity mappings, DQL etc. Adding a failing Unit or Functional Test would help us a lot - you can submit one in a Pull Request separately, referencing this bug report. --> I create a repository with an easy way to reproduce this issue. It was introduced in version `2.14.2` prior to this version it was working as expected. You could verify it by cloning the repository: https://github.com/Legion112/doctrine-playground After cloning use docker for quick setup: ``` make shell ``` After running the command below in logs you could see a wrong select statement ``` composer require doctrine/orm:2.14.2 -W && php index.php ``` I have confirmed that this version correctly was formatted correctly #### Expected behavior ``` Executing query: SELECT o0_.id AS id_0, o0_.amount AS amount_1, o0_.depositAddress AS depositAddress_2, o0_.name AS name_3, o0_.network AS network_4, o0_.type AS type_5 FROM operations o0_ WHERE o0_.type IN ('blockchain-in', 'expense') ``` <!-- What was the expected (correct) behavior? -->
admin closed this issue 2026-01-22 15:46:20 +01:00
Author
Owner

@JanTvrdik commented on GitHub (Sep 15, 2023):

This error comes from Doctrine\ORM\Query\SqlWalker::generateDiscriminatorColumnConditionSQL(), because the discriminatorValue of a intermediate subclass will be null.

It is most likely caused by https://github.com/doctrine/orm/pull/10411.

Similar issue already fixed: https://github.com/doctrine/orm/pull/10643


It also emits to following error:

Deprecated: PDO::quote(): Passing null to parameter #1 ($string) of type string is deprecated in /app/vendor/doctrine/dbal/src/Driver/PDO/Connection.php on line 84

@JanTvrdik commented on GitHub (Sep 15, 2023): This error comes from `Doctrine\ORM\Query\SqlWalker::generateDiscriminatorColumnConditionSQL()`, because the `discriminatorValue` of a intermediate subclass will be null. It is most likely caused by https://github.com/doctrine/orm/pull/10411. Similar issue already fixed: https://github.com/doctrine/orm/pull/10643 --- It also emits to following error: > Deprecated: PDO::quote(): Passing null to parameter #1 ($string) of type string is deprecated in /app/vendor/doctrine/dbal/src/Driver/PDO/Connection.php on line 84
Author
Owner

@mpdude commented on GitHub (Feb 2, 2024):

Please report in #11200 whether it fixes this issue

@mpdude commented on GitHub (Feb 2, 2024): Please report in #11200 whether it fixes this issue
Author
Owner

@Legion112 commented on GitHub (Feb 2, 2024):

I have installed the patched on my tested project
image
image

I have tested it on my playground and I confirm that the patch will fix the issue with IN statement.

image|

Some testing on real application could be done by my colleague @RalkeryBug
To test you would need to add fork repository:

    "repositories": [{
        "type": "vcs",
        "url": "https://github.com/DemoniacDeath/orm.git"
    }
    ],

Install the patch version

composer require doctrine/orm:dev-issue-11199 -W

Run the application test to make sure patch does not break anything else.

@Legion112 commented on GitHub (Feb 2, 2024): I have installed the patched on my tested project ![image](https://github.com/doctrine/orm/assets/20613430/e1a77acd-b5a4-4618-98ba-028f47888375) ![image](https://github.com/doctrine/orm/assets/20613430/b6553913-68fd-4f49-ad86-de15faa0012a) I have tested it on my playground and I confirm that the patch will fix the issue with IN statement. ![image](https://github.com/doctrine/orm/assets/20613430/fb345a8b-1945-43ad-8e71-659f158194c1)| Some testing on real application could be done by my colleague @RalkeryBug To test you would need to add fork repository: ```composer.json "repositories": [{ "type": "vcs", "url": "https://github.com/DemoniacDeath/orm.git" } ], ``` Install the patch version ```bash composer require doctrine/orm:dev-issue-11199 -W ``` Run the application test to make sure patch does not break anything else.
Author
Owner

@mpdude commented on GitHub (Feb 3, 2024):

Fixed by #11200

@mpdude commented on GitHub (Feb 3, 2024): Fixed by #11200
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7186