Skip to content

exists(false); is transformed to exists('') #2194

Closed
@Plopix

Description

@Plopix

This appears between 2.0.6 and 2.1.0

BC Break Report

Q A
BC Break yes
Version 2.1.0

Summary

The preparation does not work as expected for $exists, the current system look at the type of the property and convert it. But for $exists that should not be converted according the the type of the property tested.

it should stay a boolean.

Previous behavior

false was still false and not ""

Current behavior

false is converted to "" in the StringType convertToDatabaseValue

How to reproduce

Pretty easy:

        $qb = $this->getDocumentManager()->createAggregationBuilder($this->getClassMetadata()->name);
        $qb->match()->field('assessment')->exists(false);
        dump($qb->getPipeline());

Observe

^ array:1 [
  0 => array:1 [
    "$match" => array:1 [
      "assessment" => array:1 [
        "$exists" => false
      ]
    ]
  ]
]

then update to 2.1.0 or 2.1.1 using composer update

^ array:1 [
  0 => array:1 [
    "$match" => array:1 [
      "assessment" => array:1 [
        "$exists" => ""
      ]
    ]
  ]
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions