Hi,

I'm having trouble understanding the correct syntax to be used with
Declarative and a column property.
The select statement I'm using is:
 select([func.substr(my_table.c.my_string, 2, 3)]).label(my_substr'),
deferred=True
And (as per the docs using the expanded syntax, this works as expected.

With the Declarative syntax, I've tried:

from sqlalchemy.util                 import classproperty
from sqlalchemy.orm                ..., column_property

class MySubstr(object):
@classproperty
def my_substr(cls):
return column_property(
           select([func.substr(cls.my_str, 2, 3)]).label('my_substr')
  )

class MyTable(Base, MySubstr):
    .....

and then expect to be able to call a record in MyTable and return its
"my_substr", however, all I'm getting is a representation of the object ...
eg <sqlalchemy.orm.properties.ColumnProperty object at 0xa4951cc>  and no
apparent way of seeing its value.

Should the @classproperty sit within the "MyTable(Base)" itself (ie is there
a need for the separate object -- and have I been confused by the section on
'mixins' )?

I'd be really grateful for any clues!
Many thanks,
Rob

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to