No, it not just 99. It generated by difficult RAW SQL with hierarchy library https://github.com/marplatense/sqla_hierarchy and with recursive SQL.
FULL SQL is like http://pastebin.com/b0wGUegy It adds additional data as level, connect_path, is_leaf. I get this SQL from hierarchy library and use it in from_statement for generating Comment instances with eager loading of User table. I want only add level to python instances objects from RAW SQL. I tried add this like add new Mapper: http://pastebin.com/49vnqYJR in populate_state function: row_tuple = tuple(row) level = row_tuple[-3] dict_['level'] = level and use it: hierarchy_mapper = HierarchyMapper(model_class, model_class.__table__, non_primary=True) result = db.session.query(hierarchy_mapper).from_statement(hie_statement) where hie_statement is RAW SQL. but I can't add options contains_eager like result = result.options(contains_eager(Comment.user)) it print error: ArgumentError: Can't find property 'user' on any entity specified in this Query. Note the full path from root (Mapper|Comment|comment|non- primary) to target entity must be specified. because it non_primary mapper. How I can solve this problem? Thanks! On Oct 19, 7:04 pm, Michael Bayer <mike...@zzzcomputing.com> wrote: > On Oct 19, 2011, at 8:19 AM, lestat wrote: > > > I have such model: > > > class Test(db.Model): > > __tablename__ = 'test' > > > id = db.Column(db.Integer, primary_key=True) > > > subject = db.Column(db.String(512), nullable=False) > > > level = None > > arbitrary SQL expressions can be added to a mapping as described > athttp://www.sqlalchemy.org/docs/orm/mapper_config.html#sql-expressions.... > > > That said if it were really just "99" I'd do that at the Python level; > assuming you need some DB functionality within "level". -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.