[sqlalchemy] sqlalchemy.exc.InvalidRequestError: Mapper properties (i.e. deferred,column_property(), relationship(), etc.) must be declared as @declared_attr callables on declarative mixin classes.

2016-01-15 Thread Andreas Jung
Hi, I currently have the following mix-in class construction (based on the documentation http://docs.sqlalchemy.org/en/latest/orm/extensions/declarative/mixins.html ) Base = declarative_base() class BaseCountry(object): """ Managed through Kotti """ @declared_attr def

Re: [sqlalchemy] sqlalchemy.exc.InvalidRequestError: Mapper properties (i.e. deferred,column_property(), relationship(), etc.) must be declared as @declared_attr callables on declarative mixin classes

2016-01-15 Thread Michal Petrucha
Hi Andreas, On Fri, Jan 15, 2016 at 02:56:39AM -0800, Andreas Jung wrote: > Hi, > > I currently have the following mix-in class construction (based on the > documentation > http://docs.sqlalchemy.org/en/latest/orm/extensions/declarative/mixins.html > ) > > Base = declarative_base() > >

Re: [sqlalchemy] hybrid property / expression returns entire table

2016-01-15 Thread Simon King
What happens if you put the print statement immediately after the class definition? Is there any chance that you've got "nsa_logmstar = None" somewhere in your class definition? Here's a test script which appears to work: import math import sqlalchemy as sa import sqlalchemy.orm as saorm from

Re: [sqlalchemy] sqlalchemy.exc.InvalidRequestError: Mapper properties (i.e. deferred,column_property(), relationship(), etc.) must be declared as @declared_attr callables on declarative mixin classes

2016-01-15 Thread Michal Petrucha
On Fri, Jan 15, 2016 at 02:26:37PM +0100, Michal Petrucha wrote: > Hi Andreas, > > On Fri, Jan 15, 2016 at 02:56:39AM -0800, Andreas Jung wrote: > > Hi, > > > > I currently have the following mix-in class construction (based on the > > documentation > >

Re: [sqlalchemy] hybrid property / expression returns entire table

2016-01-15 Thread Brian Cherinka
Ahh. Thanks. Here is the class side then. Still None. In [14]: print datadb.Sample.nsa_logmstar None Brian On Friday, January 15, 2016 at 8:48:30 AM UTC-5, Simon King wrote: > > "Sample()" is an instance. "Sample" is the class. Try: > > print datadb.Sample.nsa_logmstar > > Simon > > On

Re: [sqlalchemy] hybrid property / expression returns entire table

2016-01-15 Thread Brian Cherinka
Actually, the class definition is entirely what I posted in the original message. I didn't cut anything out of that. I don't define the columns in mine, as you did. The property nsa_logmstar is not defined anywhere else in the class or in any other place in this code, or in any code that

Re: [sqlalchemy] hybrid property / expression returns entire table

2016-01-15 Thread Simon King
Does my test script produce the right output for you in your installation? What does the print statement immediately after the class definition produce? Simon > On 15 Jan 2016, at 19:10, Brian Cherinka wrote: > > Actually, the class definition is entirely what I posted in

Re: [sqlalchemy] hybrid property / expression returns entire table

2016-01-15 Thread Brian Cherinka
Here is the print immediately after my original class definition: print 'sample nsa log mstar', Sample.nsa_logmstar and the result sample nsa log mstar None When I run your script exactly as is, I get the same output as you. When I replace my class definition with yours, inside my code, as

Re: [sqlalchemy] hybrid property / expression returns entire table

2016-01-15 Thread Brian Cherinka
It looks like I needed to define the columns inside my class. That's the only difference between your class and mine. And I tested out the query and it now works, and returns the correct number of rows. In [4]: print session.query(datadb.Sample.pk).filter(datadb.Sample.nsa_logmstar < 9)

Re: [sqlalchemy] hybrid property / expression returns entire table

2016-01-15 Thread Simon King
You shouldn’t need to define the columns. Here’s another test script: ### import math import sqlalchemy as sa import sqlalchemy.orm as saorm from sqlalchemy.ext.hybrid import hybrid_property from sqlalchemy.ext.declarative import declarative_base Base =

Re: [sqlalchemy] hybrid property / expression returns entire table

2016-01-15 Thread Simon King
On Fri, Jan 15, 2016 at 6:16 AM, Brian Cherinka wrote: > I'm trying to set up a hybrid property / expression in a custom class, > that I can use in queries. I think I have the syntax correct, however the > query returns the entire table, instead of the correct subset of