-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
add 'guid' to list of exception to filter out #17668
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,14 +85,21 @@ public function getEntitiesByIds($identifier, array $values) | |
// Guess type | ||
$entity = current($qb->getRootEntities()); | ||
$metadata = $qb->getEntityManager()->getClassMetadata($entity); | ||
if (in_array($metadata->getTypeOfField($identifier), array('integer', 'bigint', 'smallint', 'guid'))) { | ||
if (in_array($metadata->getTypeOfField($identifier), array('integer', 'bigint', 'smallint'))) { | ||
$parameterType = Connection::PARAM_INT_ARRAY; | ||
|
||
// Filter out non-integer values (e.g. ""). If we don't, some | ||
// databases such as PostgreSQL fail. | ||
$values = array_values(array_filter($values, function ($v) { | ||
return (string) $v === (string) (int) $v; | ||
})); | ||
} elseif ('guid' === $metadata->getTypeOfField($identifier)) { | ||
$parameterType = Connection::PARAM_INT_ARRAY; | ||
|
||
// Like above, but we just filter out empty strings. | ||
$values = array_values(array_filter($values, function ($v) { | ||
return (string) $v !== ''; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this actually need to validate the pattern of uuids, otherwise postgresql will still break for invalid uuids. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But validation can already be done via constraint There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it cannot be done via constraint, as transforming the value is done before validating the model data (as it is necessary to build the model data). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Anyway, as I already told in PR comment, the purpose here is not validating the uuid. The purpose is just allowing empty values, otherwise an optional uuid is not working. |
||
})); | ||
} else { | ||
$parameterType = Connection::PARAM_STR_ARRAY; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is wrong. You should not change this to INT_ARRAY. Uuids are not bindable as integers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm open to suggestions. What should I do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the binding type should be a string array, not an int array