On Dec 10, 2008, at 2:24 PM, Jonathan Marshall wrote: > > I think the problem may be that for some dictionaries that are to > pickled PickleType.copy_value returns something that does not equal > the original value according to PickleType.compare_values. > > E.g. >>>> from sqlalchemy.types import PickleType >>>> p = PickleType() >>>> from decimal import Decimal >>>> d1 = {'Amt': Decimal("6420.000000000000"), 'Broker': 'A', 'F': 'B'} >>>> d2 = {'Amt0': Decimal("6420.000000000000"), 'Broker': 'A', 'F': >>>> 'B'} >>>> p.compare_values(p.copy_value(d1), d1) > False >>>> p.compare_values(p.copy_value(d2), d2) > True > > Yet: >>>> p.copy_value(d1) == d1 > True > > I can work around the issue by setting comparator=operator.eq on > PickleType however the current behaviour seems to be broken. > > I can post a test case that shows objects being flushed multiple times > if you like. I'm running SA 0.5.0rc4 on OS X 10.5.5 (using Apple's > python 2.5.1 interpreter)
this is the documented behavior and the comparator=operator.eq setting is provided for exactly the purpose of efficiently comparing objects which do implement an __eq__() that compares internal state, like that of a dict (and who also don't provide identical pickles each time). The default behavior of comparing pickles is to support user-defined objects with mutable state which do not have an __eq__() method provided. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---