mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-669: order of fields in sql query and parameters to be bound to the dbal's statement is different #822
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 (Jul 5, 2010).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user sergei.lissovski:
Hi guys,
It seems that I found a bug in the Doctrine\ORM\Persisters\BasicEntityPersister. Let me explain.
Put it simply, I have the following entity:
As you can see, there's a mandatory field called "verticalOrder", it is not intended to be managed manually but rather with a listener attached to onFlush event. ( In that listener, after a value for the verticalOrder is set, the uow::recomputeSingleEntityChangeSet() method is invoked, as it was suggested in documentation ).
The thing is that when I persist an instance of this class and then invoke flush ( without providing a value for it, the verticalOrder ), Doctrine dies silently, with no exception being thrown. The easy fix can be done with adding this piece of source code to the BasicEntityPersister on line 218:
That was the first problem I have faced with while trying to find out why my entity is not persisted. After I have delved a bit deeper, I found out
that the problem lies in *BasicEntityPersister ::_getInsertColumnList()* or in _BasicEntityPersister ::prepareUpdateData(). The thing is that order of columns in the SQL query generated by the BasicEntityPersister::_getInsertColumnList() and values to be bound to the statement and after executed is different. Line 214 in BasicEntityPersister is meant here.
In my case it was reversed, instead of parent_id, a value for verticalOrder was inserted and vice versa.
Array of parameters to be bound to the Doctrine\DBAL\Statement:
And the query that will be executed:
These snippets clearly illustrate the point.
I hope I was clear in my explanations.
I will try to devote some spare time and write tests to lock this issue, but i'm not able to say at the moment when it happens.
All the best,
Sergei Lissovski