[sqlalchemy] [Q] How to fix a circular dependency error?
Hello. A specific DML request crashed with a CircularDependencyError on our test env. I know that I should set post_update=True to the problematic relationship. The thing is I do not see the cycle and the error description is quite big. Could you please provide some guidance as to how to find the cycle from the provided error description? The error has the following two attributes: * cycles = set([ SaveUpdateState(Partner at 0x7f2be28113d0), ProcessState( ManyToOneDP(Partner.bazaar), Partner at 0x7f2be28113d0, delete=False ) ]) * all_edges = set([...]) # about a text page of data but I do not understand them. If it matters, I am still using SA v0.7. If you need more info, just ask. Thank you in advance, Ladislav Lenart -- 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. For more options, visit https://groups.google.com/d/optout.
[sqlalchemy] history and postgresql arrays
I noticed something kinda weird the other day. Let's say I have an object 'o' with two fields: num (an integer) and nums (an array of integers). Using 'inspect' and some trickery: d = dict(sa.inspect(o).attrs) d['num'].history History(added=(), unchanged=(10), deleted=()) d['nums'].history History(added=(), unchanged=[[20,30]], deleted=()) Now, if I change o.num to any other value, the history value changes (as expected): o.num = 15 d['num'].history History(added=[15], unchanged=(), deleted=[10]) But if I change the array *using append/delete/etc*: o.nums.append(40) d['nums'].history History(added=(), unchanged=[[20,30,40]], deleted=()) But if I change o.nums directly: o.nums = [ 40,50,60 ] d['nums'].history History(added=[[40,50,60]], unchanged=(), deleted=[[20,30,40]]) and that seems weird. -- Jon Software Blacksmith -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [sqlalchemy] history and postgresql arrays
On May 27, 2014, at 12:39 PM, Jon Nelson jnel...@jamponi.net wrote: I noticed something kinda weird the other day. Let's say I have an object 'o' with two fields: num (an integer) and nums (an array of integers). Using 'inspect' and some trickery: d = dict(sa.inspect(o).attrs) d['num'].history History(added=(), unchanged=(10), deleted=()) d['nums'].history History(added=(), unchanged=[[20,30]], deleted=()) Now, if I change o.num to any other value, the history value changes (as expected): o.num = 15 d['num'].history History(added=[15], unchanged=(), deleted=[10]) But if I change the array *using append/delete/etc*: o.nums.append(40) d['nums'].history History(added=(), unchanged=[[20,30,40]], deleted=()) But if I change o.nums directly: o.nums = [ 40,50,60 ] d['nums'].history History(added=[[40,50,60]], unchanged=(), deleted=[[20,30,40]]) and that seems weird. mutations like append/delete aren't detected automatically unless you use the mutable extension: http://docs.sqlalchemy.org/en/rel_0_9/orm/extensions/mutable.html# there's a note here for HSTORE but it appears to be missing for ARRAY. -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [sqlalchemy] [Q] How to fix a circular dependency error?
some improvement was made to this formatting in 0.8 or so, though even now it's not very easy to read directly. Typically I try to look at the classes and relationships being mentioned in the error and then inspect the mappings. In this case it appears like the cycle is just on the Partner class and the bazaar relationship alone. Almost as though maybe you set a Partner.bazaar to be self, e.g. pointing to itself. On May 27, 2014, at 5:48 AM, Ladislav Lenart lenart...@volny.cz wrote: Hello. A specific DML request crashed with a CircularDependencyError on our test env. I know that I should set post_update=True to the problematic relationship. The thing is I do not see the cycle and the error description is quite big. Could you please provide some guidance as to how to find the cycle from the provided error description? The error has the following two attributes: * cycles = set([ SaveUpdateState(Partner at 0x7f2be28113d0), ProcessState( ManyToOneDP(Partner.bazaar), Partner at 0x7f2be28113d0, delete=False ) ]) * all_edges = set([...]) # about a text page of data but I do not understand them. If it matters, I am still using SA v0.7. If you need more info, just ask. Thank you in advance, Ladislav Lenart -- 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. 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 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. For more options, visit https://groups.google.com/d/optout.