-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Entity form type fails when submiting an empty value for non-string identifier type on Postgres #23808
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
Comments
The problem is that empty strings could be a valid choice in other columns. For example varchar primary keys allow empty strings (in mysql and postgres for sure). So there could a real choice behind an empty value. See http://sqlfiddle.com/#!17/14518/1 Maybe the safer solution is to just also add an explicit case for |
@maryo can you create a PR? |
I know it can be valid in SQL, I'm just not sure if empty string is always treated as an empty choice or not because the Form component is quite complex (there is Your proposal covers only this exact issue (custom DBAL type named |
I guess |
@Tobion I think $databasePlatform->hasNativeGuidType() && (Type::getType($metadata->getTypeOfField($identifier))->getSQLDeclaration($identifierMapping, $databasePlatform) === $databasePlatform->getGuidTypeDeclarationSQL($identifierMapping))) This one works. But... There are still soo many Postgres types that would fail |
This PR was merged into the 2.7 branch. Discussion ---------- Filtering empty uuids in ORMQueryBuilderLoader. | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #23808 | License | MIT | Doc PR | no Commits ------- 27e8cd2 Filtering empty uuids in ORMQueryBuilderLoader.
This is almost the same issue as #14583 but I am afraid nobody would notice this old closed issue.
I am using entity type with required set to
false
and the entity's id is set to uuid type usingramsey/uuid-doctrine
package with Postgres. It uses a different doctrine type than nativeguid
- https://github.com/ramsey/uuid-doctrine/blob/master/src/UuidType.php nameduuid
. Doctrine maps it toguid
Postgres type OFC but$metadata->getTypeOfField($identifier)
returnsuuid
. So this condition is not satisfiedhttps://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php#L75
A solution would be to check native types instead.
I can send a PR... but it's actually not very nice as well as filtering out those non-integer values in the condition above.
Why can't we filter out empty strings in all cases? Or at least skip
array('')
which covers entity type when bothmultiple
andrequired
is set tofalse
(the values is an empty array in case whenmultiple
is settrue
)? Or can we? Is there a case where empty string is not an empty choice?The text was updated successfully, but these errors were encountered: