From: Mike Bayer Date: Thu, 2 Jan 2014 23:59:26 +0000 (-0500) Subject: - Fixed regression where we don't check the given name against the X-Git-Tag: rel_0_9_1~12 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6d3e563a575bcdc57c966980abc5038337505566;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Fixed regression where we don't check the given name against the correct string class when setting up a backref based on a name, therefore causing the error "too many values to unpack". This was related to the Py3k conversion. [ticket:2901] --- diff --git a/doc/build/changelog/changelog_09.rst b/doc/build/changelog/changelog_09.rst index 783c674fd7..ae706fd837 100644 --- a/doc/build/changelog/changelog_09.rst +++ b/doc/build/changelog/changelog_09.rst @@ -14,6 +14,15 @@ .. changelog:: :version: 0.9.1 + .. change:: + :tags: bug, orm + :tickets: 2901 + + Fixed regression where we don't check the given name against the + correct string class when setting up a backref based on a name, + therefore causing the error "too many values to unpack". This was + related to the Py3k conversion. + .. change:: :tags: bug, orm, declarative :tickets: 2900 diff --git a/lib/sqlalchemy/orm/relationships.py b/lib/sqlalchemy/orm/relationships.py index a4d1d43e3a..da402fbf34 100644 --- a/lib/sqlalchemy/orm/relationships.py +++ b/lib/sqlalchemy/orm/relationships.py @@ -1560,7 +1560,7 @@ class RelationshipProperty(StrategizedProperty): if not self.is_primary(): return if self.backref is not None and not self.back_populates: - if isinstance(self.backref, str): + if isinstance(self.backref, util.string_types): backref_key, kwargs = self.backref, {} else: backref_key, kwargs = self.backref diff --git a/test/orm/test_mapper.py b/test/orm/test_mapper.py index a3222bc8fd..4713bbc64b 100644 --- a/test/orm/test_mapper.py +++ b/test/orm/test_mapper.py @@ -303,6 +303,22 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): }) assert User.addresses.property is m.get_property('addresses') + def test_unicode_relationship_backref_names(self): + # test [ticket:2901] + users, Address, addresses, User = (self.tables.users, + self.classes.Address, + self.tables.addresses, + self.classes.User) + + mapper(Address, addresses) + mapper(User, users, properties={ + util.u('addresses'): relationship(Address, backref=util.u('user')) + }) + u1 = User() + a1 = Address() + u1.addresses.append(a1) + assert a1.user is u1 + def test_configure_on_prop_1(self): users, Address, addresses, User = (self.tables.users, self.classes.Address,