[sqlalchemy] Re: AttributeError: 'NoneType' object has no attribute 'dict'

2009-07-31 Thread rajasekhar911
i have upgraded to 0.5.5 Now the error changed to AttributeError: 'NoneType' object has no attribute 'modified_event' Module sqlalchemy.orm.attributes:150 in __set__ view def __set__(self, instance, value): self.impl.set(instance_state(instance), instance_dict

[sqlalchemy] Re: AttributeError: 'NoneType' object has no attribute 'dict'

2009-07-31 Thread rajasekhar911
is it because of lazy initialization? I have some other attributes in my class which are lazy initialized. But these are not mapped to columns. On Jul 31, 11:44 am, rajasekhar911 rajasekhar...@gmail.com wrote: i have upgraded to 0.5.5 Now the error changed to AttributeError: 'NoneType' object

[sqlalchemy] Simple distinct aggregates in query?

2009-07-31 Thread Nick Bower
Hi - I have a pg table with a timestamp column, and have mapped this to dateTime. I've read and re-read the sqlalchemy docs, and func source, but it's not clear to me how I adapt an existing query (constructed by session.query(...).filter(...)) to do these simple aggregates; 1) Return list of

[sqlalchemy] Re: AttributeError: 'NoneType' object has no attribute 'dict'

2009-07-31 Thread Michael Bayer
theres no way to know unless you can illustrate how to reproduce the issue fully. one hunch is that your mappers are not compiled (try calling compile_mappers()). On Jul 31, 2009, at 3:39 AM, rajasekhar911 wrote: is it because of lazy initialization? I have some other attributes in

[sqlalchemy] Re: Fetching wrong values from a query involving composite primary keys

2009-07-31 Thread Kirk Strauser
On Thursday 30 July 2009 04:26:20 pm Michael Bayer wrote: you have to get the select() syntax right: BillingInfo = relation('BillingInfo', primaryjoin=and_(Invoice.pay2addrid==BillingInfo.pay2addrid,Invoice.custom er==

[sqlalchemy] Cannot acces renamed tables in Oracle

2009-07-31 Thread david.radkow...@googlemail.com
hi I'm on a project which uses sqlalchemy to access an Oracle instance. It *used* to work fine until one day we decided to rename some of the tables. Suprisingly, sqlalchemy wouldn't be able to query those renamed tables any more! The error I get is the cumbersome ORA-00942: table or view does

[sqlalchemy] Re: Fetching wrong values from a query involving composite primary keys

2009-07-31 Thread Kirk Strauser
On Friday 31 July 2009 08:30:52 am Kirk Strauser wrote: On Thursday 30 July 2009 04:26:20 pm Michael Bayer wrote: you have to get the select() syntax right: BillingInfo = relation('BillingInfo', primaryjoin=and_(Invoice.pay2addrid==BillingInfo.pay2addrid,Invoice.cust om er==

[sqlalchemy] Re: Fetching wrong values from a query involving composite primary keys

2009-07-31 Thread Michael Bayer
Kirk Strauser wrote: On Friday 31 July 2009 08:30:52 am Kirk Strauser wrote: On Thursday 30 July 2009 04:26:20 pm Michael Bayer wrote: you have to get the select() syntax right: BillingInfo = relation('BillingInfo',

[sqlalchemy] Re: Simple distinct aggregates in query?

2009-07-31 Thread Michael Bayer
Nick Bower wrote: Hi - I have a pg table with a timestamp column, and have mapped this to dateTime. I've read and re-read the sqlalchemy docs, and func source, but it's not clear to me how I adapt an existing query (constructed by session.query(...).filter(...)) to do these simple

[sqlalchemy] Re: Fetching wrong values from a query involving composite primary keys

2009-07-31 Thread Kirk Strauser
On Friday 31 July 2009 09:16:21 am Michael Bayer wrote: you likely want to call correlate(billing_table) on your select. rows inside the subquery want to correlate outwards to the parent billing table. Resulting in: sqlalchemy.exc.InvalidRequestError: Mapper 'Mapper|BillingInfo|bllginfo'

[sqlalchemy] Re: rev:6209 in sa06 breaks MSSQL on *nix

2009-07-31 Thread Michael Bayer
try r6225 Ed Singleton wrote: Revision 6209 in the sa06 branch breaks everything with MSSQL on Mac and Linux. It's not a major problem as I've reverted back. But I'd thought I'd let you know. Stack trace follows: Traceback (most recent call last): File

[sqlalchemy] Re: Fetching wrong values from a query involving composite primary keys

2009-07-31 Thread Michael Bayer
Kirk Strauser wrote: On Friday 31 July 2009 09:16:21 am Michael Bayer wrote: you likely want to call correlate(billing_table) on your select. rows inside the subquery want to correlate outwards to the parent billing table. Resulting in: sqlalchemy.exc.InvalidRequestError: Mapper

[sqlalchemy] Creating ClauseElements programmatically in a loop

2009-07-31 Thread Kees van den Broek
Hi, I'd like to create a query at run time with any amount of filters wrapped in an 'OR'. What's the right syntax to do this? This was my best attempt so far: from sqlalchemy import * id=[1,2] q=Province.query.filter(or_(map(lambda n: Province.id == n, id)))

[sqlalchemy] Re: Creating ClauseElements programmatically in a loop

2009-07-31 Thread Michael Bayer
or_() returns the first argument if theres only one argument. youre looking for or_(*map(...)) Kees van den Broek wrote: Hi, I'd like to create a query at run time with any amount of filters wrapped in an 'OR'. What's the right syntax to do this? This was my best attempt so far: from

[sqlalchemy] Re: Fetching wrong values from a query involving composite primary keys

2009-07-31 Thread Kirk Strauser
On Friday 31 July 2009 10:19:29 am Michael Bayer wrote: BillingInfo.__table__. BillingInfo is a python class, billing_table is the Table object. After all that, it turned out that yet *another* table needed to be linked in. Here's what I finally ended up with: class Invoice(Base):

[sqlalchemy] Re: Self references randomizes insert order

2009-07-31 Thread Christopher Grebs
So, if I understand you correctly this is more some kind of bug in sqlalchemy than a problem with my code, am I right? Regards, Christopher. On Jul 26, 8:11 pm, Michael Bayer mike...@zzzcomputing.com wrote: unit of work logging can be enabled: import logging logging.basicConfig()

[sqlalchemy] Re: Self references randomizes insert order

2009-07-31 Thread Michael Bayer
Christopher Grebs wrote: So, if I understand you correctly this is more some kind of bug in sqlalchemy than a problem with my code, am I right? its a less than ideal behavior in SQLAlchemy. --~--~-~--~~~---~--~~ You received this message because you are

[sqlalchemy] Re: Problems with composite primary key and nested relations

2009-07-31 Thread Michael Bayer
the issue is that the mysql dialect assumes cursor.lastrowid applies to the first primary key column in the table. Build your tables like this and it works: table_b = Table('table_b', metadata, Column('id', Integer(), nullable=False, primary_key=True), Column('a_id', Integer(),

[sqlalchemy] Re: Problems with composite primary key and nested relations

2009-07-31 Thread Michael Bayer
On Jul 31, 2009, at 7:20 PM, Michael Bayer wrote: I will investigate a way such that the dialect more intelligently selects the primary key column which recieves AUTOINCREMENT behavior. since lots of work has been going on with last_inserted_ids() in 0.6, which is soon going to trunk, this