Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix EntityType->empty_data=null #19732

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

Closed
wants to merge 1 commit into from
Closed

Fix EntityType->empty_data=null #19732

wants to merge 1 commit into from

Conversation

pierre-H
Copy link

Q A
Branch? "master"
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
License MIT

Symfony 3.1, Doctine 2.5, PHP 7, SQL Server

With :

$builder
            ->add('users', EntityType::class, array(
                'label' => 'Users',
                'class' => 'AppBundle\Entity\Users',
                'choice_label' => 'name',
                'query_builder' => function (EntityRepository $er) {
                    return $er->createQueryBuilder('u')
                        ->orderBy('u.name', 'ASC');
                },
                'empty_data'  => null,
                'required' => false
            ))

I got an error :
SQLSTATE [42000, 8114]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Eror converting nvarchar datatype to numeric.

Symfony 3.1, Doctine 2.5, PHP 7, SQL Server

With :
```
$builder
            ->add('users', EntityType::class, array(
                'label' => 'Users',
                'class' => 'AppBundle\Entity\Users',
                'choice_label' => 'name',
                'query_builder' => function (EntityRepository $er) {
                    return $er->createQueryBuilder('u')
                        ->orderBy('u.name', 'ASC');
                },
                'empty_data'  => null,
                'required' => false
            ))
```

I got an error : 
SQLSTATE [42000, 8114]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Eror converting nvarchar datatype to numeric.
Copy link
Contributor

@lemoinem lemoinem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Status: Reviewed

Copy link
Contributor

@lemoinem lemoinem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, Sorry, I've been too fast the first time.

Thank you for the contribution.

Could you add a test to make sure the bug doesn't reappears?

Plus, if you could include the whole PR template please, each part is important. If you think one is not relevant for your PR, please leave it empty or fill it with N/A instead of removing the line entirely.

Thank you!

@HeahDude
Copy link
Contributor

This fix is wrong. If multiple option is false the empty_data should be an empty string not null since nullat this step won't be transformed properly. The docs will be fixed with symfony/symfony-docs#6265.

@fabpot fabpot closed this Nov 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants