Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PropelORMFieldGuesser not working with array type #274

Open
mirza99 opened this issue Mar 17, 2016 · 0 comments
Open

PropelORMFieldGuesser not working with array type #274

mirza99 opened this issue Mar 17, 2016 · 0 comments

Comments

@mirza99
Copy link

mirza99 commented Mar 17, 2016

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',
                );
            }
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant