mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-556: Doctrine_Expression equivalent in Doctrine2? #691
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 @doctrinebot on GitHub (Apr 29, 2010).
Jira issue originally created by user mjh_ca:
Is this possible? Examples:
@doctrinebot commented on GitHub (Apr 29, 2010):
Comment created by @beberlei:
you can do this by using Doctrine\DBAL\Types\AbstractType instances
@doctrinebot commented on GitHub (Apr 29, 2010):
Comment created by @beberlei:
http://www.doctrine-project.org/documentation/manual/2_0/en/basic-mapping#custom-mapping-types
but this does not work with sql expressions, only with php conversions
@doctrinebot commented on GitHub (Apr 29, 2010):
Comment created by mjh_ca:
Thanks. It would be great if this could be further improved upon to allow unescaped SQL expressions to be passed.
@doctrinebot commented on GitHub (Apr 30, 2010):
Comment created by romanb:
The main problem with something like this is that its really intrusive. Such expressions and SQL snippets should really not slip into the domain model. I have the feeling this should be handled at a different level/layer. Besides the obvious ORM dependency that is introduced with sth like "new Doctrine\ORM\Expression" inside the entity, what meaning has an "Expression" in the domain model? Really feels like an infrastructure concern that should be done elsewhere.
Another problem with sth like this:
is that your object won't be updated with the actual value. When it comes to default values, PHP default values should be preferred instead of database default values.
@doctrinebot commented on GitHub (Apr 30, 2010):
Comment created by mjh_ca:
@Roman That makes sense now that you point it out.
Efficient storage of an MD5 as in the second example can be implemented cleanly, as Benjamin suggested, with a simple custom mapping type. Could also do this for other "custom" efficient binary storage such as IP addresses. I'll contribute the code for a cookbook entry if you like. (it is MySQL specific and therefore non-portable, obviously).
As for the timestamp issue I think it is possible to live with that limitation of keeping it on the PHP side. Thanks for the analysis.
@doctrinebot commented on GitHub (Apr 30, 2010):
Comment created by mjh_ca:
Withdrawing the request :)
@doctrinebot commented on GitHub (Apr 30, 2010):
Issue was closed with resolution "Won't Fix"