Orm: DDC-3825: simple_array slush with empty array

Created on 14 Jul 2015  路  2Comments  路  Source: doctrine/orm

Jira issue originally created by user bigfootdd:

I'm using "doctrine/orm": v2.5.0 and have simple_array type.
If I persist the class where the property with type simple_array is empty array() the query fails.

I'm coming with solution, please see the github PR https://github.com/doctrine/dbal/pull/877

Bug

Most helpful comment

Comment created by bigfoot:

I've mapped the field as nullable=false, so it should never be null.
If you cannot merge this quickly, you should at least add an warning in the docs saying that the field must be mapped set as nullable.

All 2 comments

Comment created by bigfoot:

I've mapped the field as nullable=false, so it should never be null.
If you cannot merge this quickly, you should at least add an warning in the docs saying that the field must be mapped set as nullable.

As alternative, I put filter in getter and setter methods:

public function setFields(array $values): void
{
    $this->fields = array_filter($values) ?: [null];
}

public function getFields(): array
{
   return array_filter($this->fields);
}

Note: It obviously doesn't work if you want to store empty values

Was this page helpful?
0 / 5 - 0 ratings

Related issues

doctrinebot picture doctrinebot  路  4Comments

dmaicher picture dmaicher  路  3Comments

weaverryan picture weaverryan  路  3Comments

doctrinebot picture doctrinebot  路  4Comments

doctrinebot picture doctrinebot  路  4Comments