On 03/26/2016 12:06 PM, Ricardo Champa wrote:
AFAIK merge performs and |insert or update| so what I'm doing is pretty simple. There is a relation of 1 to N between Hubs and Tags. So when I try to make a merge on tag and hub, hub goes well and load from DB the existent hub and make an update, but fails when |db.session.merge(nuevo_tag)| is executed throwing an exception because behind the scenes is try to make an insert, even if the tag previously exist. What I did wrong? |nuevo_hub =Hub(guid_hub,name,location,comments,id_project,creado_en,actualizado_en)merged_hub =db.session.merge(nuevo_hub)#db.session.commit() # If I use this line tags perform an insert.nuevo_tag =Tag(guid_tag,project,merged_hub,TYPE_HUB,creado_en,actualizado_en)merged_tag =db.session.merge(nuevo_tag)db.session.commit()|
nothing seems wrong with the small amount code pictured and also i don't know what exception you are getting, nor do I have enough context to understand the issue in general, so please provide minimal, working mappings and a demonstration per the guidelines at http://stackoverflow.com/help/mcve, thanks!
-- 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 [email protected] <mailto:[email protected]>. To post to this group, send email to [email protected] <mailto:[email protected]>. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
-- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
