diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-01-02 18:59:26 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-01-02 18:59:26 -0500 |
commit | 6d3e563a575bcdc57c966980abc5038337505566 (patch) | |
tree | 006534cf0d982766ea4acd2f738df70b64fb816d | |
parent | 8a7fdd4e5cf5e4d9ba71c66a06bcba6b1054cfef (diff) | |
download | sqlalchemy-6d3e563a575bcdc57c966980abc5038337505566.tar.gz |
- 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]
-rw-r--r-- | doc/build/changelog/changelog_09.rst | 9 | ||||
-rw-r--r-- | lib/sqlalchemy/orm/relationships.py | 2 | ||||
-rw-r--r-- | test/orm/test_mapper.py | 16 |
3 files changed, 26 insertions, 1 deletions
diff --git a/doc/build/changelog/changelog_09.rst b/doc/build/changelog/changelog_09.rst index 783c674fd..ae706fd83 100644 --- a/doc/build/changelog/changelog_09.rst +++ b/doc/build/changelog/changelog_09.rst @@ -15,6 +15,15 @@ :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 a4d1d43e3..da402fbf3 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 a3222bc8f..4713bbc64 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, |