mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Deprecate type inference in Query::setParameter
#6584
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @beberlei on GitHub (Dec 6, 2020).
We should assume every object passed must be an entity or specify a $type as third argument. Only primitive types should work with type inference. A deprecation is in order to allow users. to migrate of this behavior.
Problems with type inference:
DateTime, todatetimeordatetime_utc. https://github.com/doctrine/orm/issues/6443@beberlei commented on GitHub (Dec 8, 2020):
In addition we should think about differentiating between
setParameterfor single valued paraemters andsetParameterListfor an array of values of the specified type. Then this could allow support for arrays of more complex types:@beberlei commented on GitHub (May 1, 2021):
Needs more research
@sips-richard commented on GitHub (Apr 14, 2022):
The optional type argument on setParameter() and the baked in behaviour of inferType() for booleans and datetimes is confusing and sets the wrong expectation for consumers. I've just been digging into this to understand why these types were treated differently from other registered types. We will be updating our company coding standard to mandate that the type is always specified for consistency and clarity (obviously Connection::PARAM_STR_ARRAY etc. isn't ideal). I would welcome this change in Doctrine.