python - SQLAlchemy raises exception on query when with_polymorphic used for model with order_by mapper arg presented with string -


i've stuck 1 issue when using sqla inheritance (i have mixin __mapper_args__ set there).

to reproduce it:

  • model should have __mapper_arg__ attribute order_by param set string.
  • add with_polymorphic('*') call query model.
class user(base):     id = column(integer, primary_key=true)     name = column(string)      __mapper_args__ = {'order_by': 'user.name'} 

with constructions works fine except when add with_polymorphic('*') query.

db.query(user).with_polymorphic('*') 

this fails exception

file "/python2.7/dist-packages/sqlalchemy/sql/visitors.py", line 267, in clone     'no_replacement_traverse' in elem._annotations: attributeerror: 'str' object has no attribute '_annotations' 

i suppose kind of bug. since reproduces on sqla 0.7-0.9 have doubts way i've run issue. maybe wrong?

this issue reproduced on small testcase.


p.s.

originally needed mixin in project:

class docmixin(object):      id = column(integer)     title = column(string(255))      @declared_attr     def __mapper_args__(cls):         return {'order_by': 'title'} 

don't use strings in order_by mapper parameter, use column directly. changing 'user.name' name makes example pass tests.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -