From fdc92f0226779d608a5082e2f9009a332c142eb1 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 12 Feb 2012 17:28:20 -0500 Subject: - [bug] Fixed bug whereby if a method name conflicted with a column name, a TypeError would be raised when the mapper tried to inspect the __get__() method on the method object. [ticket:2352] --- lib/sqlalchemy/orm/mapper.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'lib/sqlalchemy/orm') diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index 42acb4928..e96b7549a 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -1452,12 +1452,19 @@ class Mapper(object): return result def _is_userland_descriptor(self, obj): - return not isinstance(obj, - (MapperProperty, attributes.QueryableAttribute)) and \ - hasattr(obj, '__get__') and not \ - isinstance(obj.__get__(None, obj), - attributes.QueryableAttribute) - + if isinstance(obj, (MapperProperty, + attributes.QueryableAttribute)): + return False + elif not hasattr(obj, '__get__'): + return False + else: + obj = util.unbound_method_to_callable(obj) + if isinstance( + obj.__get__(None, obj), + attributes.QueryableAttribute + ): + return False + return True def _should_exclude(self, name, assigned_name, local, column): """determine whether a particular property should be implicitly -- cgit v1.2.1