Skip to content

Custom types converted to database value by __toString() in loadAll instead of Type::convertToDatabaseValue() #11405

@hlib-kuznetsov

Description

@hlib-kuznetsov

Bug Report

Q A
BC Break idk
Version 3.1.1

Summary

When eager relations are loaded by BasicEntityPersister::loadAll()

[$params, $types] = $this->expandParameters($criteria);

There only 3 options for array type - STRING, INTEGER and ASCII

return match ($type) {
ParameterType::STRING => ArrayParameterType::STRING,
ParameterType::INTEGER => ArrayParameterType::INTEGER,
ParameterType::ASCII => ArrayParameterType::ASCII,
};

So any custom type will be narrowed to one of those types, based on Type::getBindingType() or will fail.

var_dump($criteria);
[$params, $types] = $this->expandParameters($criteria);
var_dump($params, $types);
array(1) {
  [0]=>
  array(1) {
    [0]=>
    object(Symfony\Component\Uid\Ulid)#814 (1) {
      ["uid":protected]=>
      string(26) "01HKQA3CFEMF71KWYC3QN7W87K"
    }
  }
}
array(1) {
  [0]=>
  enum(Doctrine\DBAL\ArrayParameterType::STRING)
}

Then when \Doctrine\DBAL\Connection binds values using Type::convertToDatabaseValue() any custom type, including Symfony\Uuid will be converted using STRING, INTEGER or ASCII convertToDatabaseValue(), not the type's one.

Current behavior

Eager relations refering to custom types are not loaded which leads to additional lazy queries

How to reproduce

Try eager loading when relation refers to column with any custom type, including uuid

Expected behavior

Custom types are bound to statement using convertToDatabaseValue(), not using __toString()

Metadata

Metadata

Assignees

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