a bug, fixed in r4834 of 0.4 branch and r4835 of the trunk.
On Jun 3, 2008, at 10:15 AM, Martin Pengelly-Phillips wrote: > > > Hi there, > > In SA 0.4.6 I get the following failure when attempting to merge an > object that contains a ComparableProperty: >> .... >> prop.merge(self, instance, merged, dont_load, _recursive) >> TypeError: merge() takes exactly 4 arguments (6 given) > > Is this something I am doing wrong or a bug? > > ta, > > Martin > > --------------- > > import sqlalchemy > from sqlalchemy import Column, Table, types > from sqlalchemy.orm import relation, comparable_property > from sqlalchemy.orm.interfaces import PropComparator > > engine = sqlalchemy.create_engine('sqlite:///', echo=False) > metadata = sqlalchemy.MetaData() > metadata.bind = engine > Session = > sqlalchemy > .orm.scoped_session(sqlalchemy.orm.sessionmaker(autoflush=True, > transactional=True, bind=engine)) > mapper = Session.mapper > > > class PolymorphicProperty(object): > > class Comparator(PropComparator): > def __eq__(self, other): > return self._value == other._value > > def __init__(self, key=None, value=None): > self.key = key > self.value = value > > def _getValue(self): > return self._value > > def _setValue(self, value): > setattr(self, '_value', value) > > value = property(_getValue, _setValue) > > def __str__(self): > return '<%s:%s %s=%s>' % (self.__class__.__name__, self.id, > self.key, self.value) > > table = Table('polymorphicProperties', metadata, > Column('id', types.Integer, primary_key=True), > Column('key', types.String(20), nullable=False, > default='keyword'), > Column('_value', types.Text, default=None), > ) > > mapper(PolymorphicProperty, > table, > properties={ > 'value': > comparable_property(PolymorphicProperty.Comparator, > PolymorphicProperty.value), > } > ) > > metadata.create_all(engine) > > sess = Session() > sess.begin() > prop = PolymorphicProperty(key='name', value='Bob') > sess.commit() > print prop > sess.expunge(prop) > Session.remove() > > sess = Session() > # This Fails > sess.merge(prop) > Session.remove() > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---