On Jun 5, 2013, at 3:52 AM, Etienne Rouxel <rouxel.etie...@gmail.com> wrote:

> 
> However, I get confused by SQLAlchemy trying to set taxon_id to NULL or even 
> worse,

please keep in mind that this was within an autoflush, in between where the 
state of your object graph in memory was complete.  If the flush were to 
succeed, upon the next flush the row would be updated again to the correct 
value.   This is why its important that autoflush run within a transaction.


> by SQLAlchemy trying to delete the plant if I configure a "cascade='all, 
> delete-orphan'" on the backref side of the relationship. I understand that it 
> might not be "easy" for SQLAlchemy to understand what I am trying to do, but 
> the fact that I end up with two different results depending on whether or not 
> taxon_old is previously loaded is confusing.

one-to-one relationships have problems in this area, and I can also show you 
versions of your test where a single Taxon gets more than one Plant assigned to 
it, which would then return more than one row for that relationship (SQLAlchemy 
emits a warning when this condition is detected).    That's really the main 
concern in this area - SQLAlchemy's load in this case is to detect this 
condition but it can be defeated.




-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to