[sqlalchemy] Re: Correct way of moving relation

2009-01-30 Thread Werner F. Bruhin
Michael, Michael Bayer wrote: oh, duh. do it like this: for purchase in list(aItem.purchase): purchase.cbbottle = bItem I leave it to you as an exercise why this is the case. aItem.purchase is an instrumented list and as such is mutable, is that the right conclusion? Thanks

[sqlalchemy] Re: Getting ForeignKey Before Commit

2009-01-30 Thread Werner F. Bruhin
n00b wrote: why don't you work off the las/previous committed rec id? On Jan 29, 4:05 am, Dejan Mayo dejan.m...@gmail.com wrote: Hi, My code is like that: try: for some_val in some_values: rec = SomeModel() rec.some_val = some_val session.save(rec)

[sqlalchemy] Using orderedlist with a secondary table

2009-01-30 Thread Nathan Harmston
Hi, I am currently trying to make a relation between Document and Author, where there is a many to many association which is dealt with by a secondary table and I am trying to store the position of an author in the author list. mapper(Paper, document_table, properties={'journal':relation(Journal,

[sqlalchemy] Re: Using orderedlist with a secondary table

2009-01-30 Thread King Simon-NFHD78
-Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of Nathan Harmston Sent: 30 January 2009 13:15 To: sqlalchemy@googlegroups.com Subject: [sqlalchemy] Using orderedlist with a secondary table Hi, I am currently trying to make

[sqlalchemy] Re: (InterfaceError) connection already closed

2009-01-30 Thread Michael Bayer
On Jan 30, 2009, at 5:50 AM, Alessandro Dentella wrote: Hi, i'm trying to understand how to cope with errors from the database and I don't completely understand the following behaviour. I try to delete a Project that has integrity constrains, so correctly the db complains and

[sqlalchemy] Re: find only loaded objects in relation collections

2009-01-30 Thread jason kirtland
GHZ wrote: Hi, I have a Subscriber and an Address table. Subscriber can have many Addresses mapper(Subscriber, subscriber_table, properties={ 'addresses' : relation(Address, collection_class=Addresses, backref='customer')}) From the a Subscriber object, I want to inspect all

[sqlalchemy] polymorphic_identity not allowed to be zero for base class?

2009-01-30 Thread Gunnlaugur Thor Briem
Hi, [trying to send this again, seems like previous copy got lost in some moderation queue] Messing with single-table inheritance in a declarative model, with a non-abstract base class, I find that querying fails if polymorphic_identity is 0 (zero). Example: code begins

[sqlalchemy] Re: polymorphic_identity not allowed to be zero for base class?

2009-01-30 Thread Michael Bayer
its likely a bug. there are some boolean tests for polymorphic_identity in mapper.py which should be changed to is None. On Jan 30, 2009, at 11:58 AM, Gunnlaugur Thor Briem wrote: Hi, [trying to send this again, seems like previous copy got lost in some moderation queue] Messing

[sqlalchemy] Re: polymorphic_identity not allowed to be zero for base class?

2009-01-30 Thread King Simon-NFHD78
Would None (ie. SQL NULL) be a valid polymorphic identity? -Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of Michael Bayer Sent: 30 January 2009 17:06 To: sqlalchemy@googlegroups.com Subject: [sqlalchemy] Re:

[sqlalchemy] Re: polymorphic_identity not allowed to be zero for base class?

2009-01-30 Thread Michael Bayer
On Jan 30, 2009, at 12:19 PM, King Simon-NFHD78 wrote: Would None (ie. SQL NULL) be a valid polymorphic identity? it becomes that issue where we just need some kind of constant to represent THIS_IS_NOT_DEFINED, so that we know when polymorphic_identity is defined or not. it's a

[sqlalchemy] Re: polymorphic_identity not allowed to be zero for base class?

2009-01-30 Thread King Simon-NFHD78
-Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of Michael Bayer Sent: 30 January 2009 17:25 To: sqlalchemy@googlegroups.com Subject: [sqlalchemy] Re: polymorphic_identity not allowed to be zero for base class? On Jan 30,

[sqlalchemy] Re: (InterfaceError) connection already closed

2009-01-30 Thread Alessandro Dentella
connection already closed is a psycopg2 error indicating that the socket has been shut down. looking at your output, I see a raw execute() occuring within the string conversion of your Project object and theres a module called sqlkit/db/utils.py causing an exception throw. SQLA's

[sqlalchemy] Filtering lazy='dynamic' collection on class type (single-table inheritance)

2009-01-30 Thread Hans Lellelid
Hi, I did a quick search but couldn't find the right way to do this in SA. For the sake of example, I have a many-to-many relationshp between Book and Reader. The 'books' property of reader is loaded using lazy='dynamic'. And, finally, Book is mapped with single-table inheritance and has

[sqlalchemy] Re: (InterfaceError) connection already closed

2009-01-30 Thread Michael Bayer
On Jan 30, 2009, at 12:38 PM, Alessandro Dentella wrote: connection already closed is a psycopg2 error indicating that the socket has been shut down. looking at your output, I see a raw execute() occuring within the string conversion of your Project object and theres a module called

[sqlalchemy] Re: Filtering lazy='dynamic' collection on class type (single-table inheritance)

2009-01-30 Thread Michael Bayer
On Jan 30, 2009, at 1:39 PM, Hans Lellelid wrote: Hi, I did a quick search but couldn't find the right way to do this in SA. For the sake of example, I have a many-to-many relationshp between Book and Reader. The 'books' property of reader is loaded using lazy='dynamic'. And,

[sqlalchemy] Re: Filtering lazy='dynamic' collection on class type (single-table inheritance)

2009-01-30 Thread Hans Lellelid
On Jan 30, 2:37 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Jan 30, 2009, at 1:39 PM, Hans Lellelid wrote: Hi, I did a quick search but couldn't find the right way to do this in SA. For the sake of example, I have a many-to-many relationshp between Book and Reader.  

[sqlalchemy] Re: Equivalent of UPDATE ... WHERE ... in ORM?

2009-01-30 Thread James
Perfect - thanks Mike! As I'm using 0.4 (sorry, neglected to mention that) I've gone for the table.update(...).execute() option and it works a treat. On Jan 25, 12:25 am, Michael Bayer mike...@zzzcomputing.com wrote: the update() method on Query accomplishes this.  Make sure you read   the