Skip to content

Cannot differ between TRUE/FALSE and 1/0 in DQL (needed for JSON data) #7550

Open
@Hikariii

Description

@Hikariii

Bug Report

Q A
BC Break no
Version 2.6.3

Summary

For all db implementations the SqlWalker uses the Platform to convert a boolean literal to an SQL representation. The default behaviour is to convert a boolean to 0 or 1 respectively. As the mysql documentation also states as its behaviour: https://dev.mysql.com/doc/refman/5.7/en/boolean-literals.html

Since mysql 5.7 with JSON functions there is a different behaviour though.
Consider this query:
SELECT JSON_SET('{ "a": 0, "b": false}', '$.a', 1, '$.b', TRUE);
results in the json object:
{"a": 1, "b": true}

Here TRUE and 1 yield a different result.

Current behavior

Using DQL extension https://github.com/ScientaNL/DoctrineJsonFunctions to be able to have JSON functions enabled the DQL generates incorrect sql:

lang query
DQL SELECT JSON_SET('{ "a": 0, "b": false}', '$.a', 1, '$.b', TRUE);
SQL generated SELECT JSON_SET('{ "a": 0, "b": false}', '$.a', 1, '$.b', 1);
SQL expected SELECT JSON_SET('{ "a": 0, "b": false}', '$.a', 1, '$.b', TRUE);

How to reproduce

Generate sql from DQL SELECT TRUE.
This will yield the SQL: SELECT 1.

Expected behavior

The expected behaviour is to be able to differ between 1 and TRUE in DQL and generate a query like SELECT TRUE

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