Re: [sqlalchemy] aliased in mixins

2012-08-01 Thread Sergey Kucheryavski
).where(cls.parent_id == > mptt2.id)) > > > > > On Aug 1, 2012, at 7:20 AM, Sergey Kucheryavski wrote: > > Thanks Michael, I greatly appreciate your help. But I am still a bit > confused. To set the attribute I need to have the alias for MPTT (or, > actually any class t

Re: [sqlalchemy] aliased in mixins

2012-08-01 Thread Sergey Kucheryavski
the mapping error. On Wednesday, August 1, 2012 3:46:56 AM UTC+2, Michael Bayer wrote: > > > On Jul 31, 2012, at 11:42 AM, Sergey Kucheryavski wrote: > > I would like to use Mixin to make a base class for MPTT trees, just as an > example > > class MPTT(object): >

[sqlalchemy] aliased in mixins

2012-07-31 Thread Sergey Kucheryavski
I would like to use Mixin to make a base class for MPTT trees, just as an example class MPTT(object): @declared_attr def __tablename__(cls): return cls.__name__.lower() id = db.Column(db.Integer, primary_key = True) level = db.Column(db.Integer, nullable = False) lft

Re: [sqlalchemy] group_concat, op and separator

2012-07-27 Thread Sergey Kucheryavski
t; operators._PRECEDENCE['SEPARATOR'] = 0 > > expr = > func.group_concat(column('urlname').op('SEPARATOR')(literal_column('/'))) > > print expr > > > > On Jul 22, 2012, at 8:30 AM, Sergey Kucheryavski wrote: > > I try to use gro

[sqlalchemy] group_concat, op and separator

2012-07-22 Thread Sergey Kucheryavski
I try to use group_concat with SEPARATOR option as it was proposed in other topic but got a strange issue with using group_concat and op: this expression: print node.urlname.op('SEPARATOR')('/') gives node.urlname SEPARATOR :urlname_1 But this expression print func.group_concat(node.urlname.op('

Re: [sqlalchemy] Complex queries and pseudo fields

2012-07-22 Thread Sergey Kucheryavski
Well it works properly, thanks once again! On Sunday, July 22, 2012 9:01:29 AM UTC+2, Sergey Kucheryavski wrote: > > Then I perhaps did not understand how to use column_property correctly. I > mean one can do this: > > n2 = aliased(Node) > sel = select([group_concat(.

Re: [sqlalchemy] Complex queries and pseudo fields

2012-07-22 Thread Sergey Kucheryavski
class is defined, after class definition. And in this case it is not possible to use url field in queries. Will try to read documentation more carefully once again. Thanks a lot! On Saturday, July 21, 2012 10:04:23 PM UTC+2, Michael Bayer wrote: > > > On Jul 21, 2012, at 3:23 PM,

Re: [sqlalchemy] Complex queries and pseudo fields

2012-07-21 Thread Sergey Kucheryavski
t >= self.rgt).order_by(Node.lft) return db.session.execute(sel).first()['url'].replace(',', '/') Is it better or worse alternative to column_property in this case? Thanks a lot in advance! On Friday, July 20, 2012 4:00:17 PM UTC+2, Michael Bayer wr

[sqlalchemy] Complex queries and pseudo fields

2012-07-20 Thread Sergey Kucheryavski
Hello, I want to use a table and ORM for keeping and managing tree of static web pages with MPTT approach. The class/table itself is rather simple: class Node(db.Model): __tablename__ = 'node' id = db.Column(db.Integer, primary_key = True) parent_id = db.Column(db.Integer, db.Foreign