1. Christoph Zwerschke
  2. sqlalchemy


Mike Bayer  committed bf301b9

merged merge fix from r4834/rel_0_4 branch

  • Participants
  • Parent commits 31be048
  • Branches default

Comments (0)

Files changed (5)


View file
       will alias() the secondary (association) table so
       that multiple contains() calls will not conflict
       with each other [ticket:1058]
+    - fixed bug preventing merge() from functioning in 
+      conjunction with a comparable_property()
 - mysql
     - Added 'CALL' to the list of SQL keywords which return

File lib/sqlalchemy/databases/postgres.py

View file
             text += " OFFSET " + str(select._offset)
         return text
-    def get_select_precolumns(self, select):
+    def dont_get_select_precolumns(self, select):
         if select._distinct:
             if isinstance(select._distinct, bool):
                 return "DISTINCT "

File lib/sqlalchemy/orm/interfaces.py

View file
         return not self.parent.non_primary
-    def merge(self, session, source, dest):
+    def merge(self, session, source, dest, dont_load, _recursive):
         """Merge the attribute represented by this ``MapperProperty``
         from source to destination object"""

File lib/sqlalchemy/orm/properties.py

View file
         strategies.DefaultColumnLoader(self)._register_attribute(None, None, False, comparator_callable, proxy_property=self.descriptor)
-    def merge(self, session, source, dest, _recursive):
+    def merge(self, session, source, dest, dont_load, _recursive):
 SynonymProperty.logger = log.class_logger(SynonymProperty)
     def create_row_processor(self, selectcontext, path, mapper, row, adapter):
         return (None, None)
+    def merge(self, session, source, dest, dont_load, _recursive):
+        pass
 class PropertyLoader(StrategizedProperty):
     """Describes an object property that holds a single item or list

File test/orm/merge.py

View file
 import testenv; testenv.configure_for_tests()
 from testlib import sa, testing
 from testlib.sa.util import OrderedSet
-from testlib.sa.orm import mapper, relation, create_session
+from testlib.sa.orm import mapper, relation, create_session, PropComparator, synonym, comparable_property
 from testlib.testing import eq_, ne_
 from orm import _base, _fixtures
         except sa.exc.InvalidRequestError, e:
             assert "dont_load=True option does not support" in str(e)
+    @testing.resolve_artifact_names
+    def test_synonym_comparable(self):
+        class User(object):
+           class Comparator(PropComparator):
+               pass
+           def _getValue(self):
+               return self._value
+           def _setValue(self, value):
+               setattr(self, '_value', value)
+           value = property(_getValue, _setValue)
+        mapper(User, users, properties={
+            'uid':synonym('id'),
+            'foobar':comparable_property(User.Comparator,User.value),
+        })
+        sess = create_session()
+        u = User()
+        u.name = 'ed'
+        sess.save(u)
+        sess.flush()
+        sess.expunge(u)
+        sess.merge(u)
 if __name__ == "__main__":