Skip to content

Documentation about simple_array type suggests it can return null, an empty array is returned instead #7098

@holtkamp

Description

@holtkamp

https://github.com/doctrine/dbal/blob/4.3.x/docs/en/reference/types.rst#simple_array
https://github.com/doctrine/dbal/blob/4.4.x/docs/en/reference/types.rst#simple_array
https://github.com/doctrine/dbal/blob/5.0.x/docs/en/reference/types.rst#simple_array

all end with:

Values retrieved from the database are always converted to PHP's array type using comma delimited explode() or null if no data is present.

The last sentence "or null if no data is present." seems not the way it is implemented: in case no data is present, an empty array is returned according to:

https://github.com/doctrine/dbal/blob/4.3.x/src/Types/SimpleArrayType.php#L43-L45

To me that seems incorrect. An empty array is a different value than NULL. NULL is no value. Why isn't NULL returned as the documentations states? And if the current implementation is the "agreed upon approach", then the documentation should be changed to indicate an array is always returned?

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