Skip to content

PropelORMFieldGuesser not working with array type #274

@mirza99

Description

@mirza99

Hi,

I think I found a bug.
I have an array type in the schema : <column name="roles" type="array" required="false" />
So I have an exception : Error: Call to a member function getType() on boolean that occurs in PropelORMFieldGuesser.
It's because in PropelORMFieldGuesser::getOptions() the parameter $type is set to Symfony\Component\Form\Extension\Core\Type\CollectionType. And that's ok (see : here )

So I added at the beginning of the function getOptions() :

if ('virtual' === $dbType || 'ARRAY' == $dbType)
  {
            return array();
  }

*EDIT : *

Another solution is :
At line 328 of PropelORMFieldGuesser :

if (preg_match("#CollectionType$#i", $type)) {
            $relation = $this->getRelation($columnName, $class);

            if ($relation) {
                return array(
                    'allow_add'     => true,
                    'allow_delete'  => true,
                    'by_reference'  => false,
                    'entry_type' => 'entity',
                    'entry_options' => array(
                        'class' => \RelationMap::MANY_TO_ONE === $relation->getType() ? $relation->getForeignTable()->getClassname() : $relation->getLocalTable()->getClassname()
                    )
                );
            }else{
                return array(
                    'entry_type' => 'text',
                );
            }
        }

Metadata

Metadata

Assignees

No one assigned

    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