mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-2012: Inserting a new entity with a custom mapping type does not call convertToDatabaseValueSQL() when using InheritanceType("JOINED") #2538
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 (Sep 4, 2012).
Jira issue originally created by user darklow:
When using class type inheritance - @InheritanceType("JOINED") and inserting new entity with a custom mapping type, custom type method convertToDatabaseValueSQL() is never called.
Here is sample class mapping:
I am using the same custom TsvectorType with simple entities and even Mapped Superclasses and it works perfectly, however on InheritanceType("JOINED") method convertToDatabaseValueSQL() is never called :/
Hope someone knows how to fix this.
Thank you.
@doctrinebot commented on GitHub (Sep 24, 2012):
Comment created by @FabioBatSilva:
Hi Kaspars,
I can't reproduce,
Could you change the added testcase and try to make it fails ?
Thanks
@doctrinebot commented on GitHub (Sep 26, 2012):
Comment created by darklow:
@Fabio thanks for looking into my problem
I attached test where you can detect the problem.
It was quite strange, all i did was changed column that uses custom type to array and some minimal convertToDatabaseValue and convertToDatabaseValueSQL logic and convertToDatabaseValueSQL was never called.
One more thing i noticed, this bug only appears on persist and not on merge.
Thanks
@doctrinebot commented on GitHub (Sep 29, 2012):
Comment created by @FabioBatSilva:
Thanks Kaspars :)
But sorry, I dont get your use case.
Notice that convertToDatabaseValueSQL is called just when using queries to find a object by a especific columns which is your mapping type.
http://docs.doctrine-project.org/en/2.1/cookbook/advanced-field-value-conversion-using-custom-mapping-types.html#the-mapping-type
@doctrinebot commented on GitHub (Sep 29, 2012):
Comment created by darklow:
I am using PostgreSQL tsvector data type for full text search.
Here is my tsvector custom data type class:
https://gist.github.com/3129096
The only way to update this field in postgresql is to use postgresql function to_tsvector('some text').
And everything works fine, if i persist simple entity, this method transforms insert query as needed:
But when i use inheritance, then by some reason convertToDatabaseValueSQL method is not called and tsv field is updated with simple text as returned by convertToDatabaseValue() method.
I modified the Ticket Test so that you can see exact moment of when it is not called, which is exactly my problem.
Here is the result after persisting (for persist it failed)
Here is the result after second time update (now by tsv format you can see it worked):
@doctrinebot commented on GitHub (Sep 30, 2012):
Comment created by @FabioBatSilva:
Thanks Kaspars
Now i saw the problem
Writing a patch ...
@doctrinebot commented on GitHub (Oct 3, 2012):
Issue was closed with resolution "Fixed"
@doctrinebot commented on GitHub (Oct 3, 2012):
Comment created by darklow:
Just tested fixed version and everything works perfectly now.
Thank you!
@doctrinebot commented on GitHub (Oct 3, 2012):
Comment created by @FabioBatSilva:
Fixed by :
91caff1d89