[sqlalchemy] Batch Delete with ORM

2010-10-04 Thread Mark Erbaugh
I have a table described with: BASE = declarative_base(name=APP_ID) class Period(BASE): __tablename__ = 'period' realperiod = Column(Integer, primary_key=True) cycle = Column(Integer) [more columns] I want to delete all records with a given value for the cycle column.

[sqlalchemy] (IntegrityError) null value in column post_id violates not-null constraint

2010-10-04 Thread Anton Shestakov
Hello all, So, here's simple script that produces the error: http://pastie.org/1197851 please take a look at it, the script isn't big at all and there's traceback for the error as well. In short, it issues a query to get a simple object (Post) with one-to-many relation tag_links (i.e. array of

Re: [sqlalchemy] (IntegrityError) null value in column post_id violates not-null constraint

2010-10-04 Thread Michael Bayer
On Oct 4, 2010, at 1:34 AM, Anton Shestakov wrote: Hello all, So, here's simple script that produces the error: http://pastie.org/1197851 please take a look at it, the script isn't big at all and there's traceback for the error as well. In short, it issues a query to get a simple object

[sqlalchemy] Cannot deepcopy() model instance with attribute mapped collection on it

2010-10-04 Thread Nikolaj
Hey, I had trouble deepcopying model instances that use attribute mapped collection classes. I'm aware that copying an instance implies a certain use case with a better solution - I accidentally hit this error when I had an instance as an attribute on an object I was deepcopy()ing. The following

[sqlalchemy] collection_class = set

2010-10-04 Thread Mark Erbaugh
I'm trying to use a relationship that uses a set as the collection_class by setting the collection_class parameter to set. I chose a set since there should only be one instance corresponding to a give table row since it is enforced by a foreign key on the many side. When initially populating

[sqlalchemy] Re: Unexpected behavior of is_modified()

2010-10-04 Thread Ted Turocy
Hi, On Sep 27, 11:53 pm, Michael Bayer mike...@zzzcomputing.com wrote: This is a limitation of is_modified(), and it is definitely a bug here that this limitation is not documented (ticket 1928). Thanks. I could probably be prevailed upon to submit a documentation patch once I'm sure I

Re: [sqlalchemy] Re: Unexpected behavior of is_modified()

2010-10-04 Thread Michael Bayer
On Oct 4, 2010, at 5:32 PM, Ted Turocy wrote: Hi, On Sep 27, 11:53 pm, Michael Bayer mike...@zzzcomputing.com wrote: This is a limitation of is_modified(), and it is definitely a bug here that this limitation is not documented (ticket 1928). Thanks. I could probably be prevailed upon

Re: [sqlalchemy] Batch Delete with ORM

2010-10-04 Thread Michael Bayer
On Oct 4, 2010, at 8:16 AM, Mark Erbaugh wrote: I have a table described with: BASE = declarative_base(name=APP_ID) class Period(BASE): __tablename__ = 'period' realperiod = Column(Integer, primary_key=True) cycle = Column(Integer) [more columns] I want

[sqlalchemy] MySQL DATE_ADD function

2010-10-04 Thread Bryan
I'm having trouble converting this SQL into an ORM statement. DATE_ADD(datecol, INTERVAL(1 - DAYOFWEEK(datecol)) DAY) This is as far as I can get, which is basically nowhere. The second argument to date_add requires literal strings INTERVAL and DAY, but I also need to insert a function in the

Re: [sqlalchemy] (IntegrityError) null value in column post_id violates not-null constraint

2010-10-04 Thread Anton Shestakov
2010/10/4 Michael Bayer mike...@zzzcomputing.com: On Oct 4, 2010, at 1:34 AM, Anton Shestakov wrote: Hello all, So, here's simple script that produces the error: http://pastie.org/1197851 please take a look at it, the script isn't big at all and there's traceback for the error as well. In

Re: [sqlalchemy] Batch Delete with ORM

2010-10-04 Thread Mark Erbaugh
On Oct 4, 2010, at 5:46 PM, Michael Bayer wrote: On Oct 4, 2010, at 8:16 AM, Mark Erbaugh wrote: I have a table described with: BASE = declarative_base(name=APP_ID) class Period(BASE): __tablename__ = 'period' realperiod = Column(Integer, primary_key=True)

[sqlalchemy] reconstruct_instance not being called when adding an extension dynamically

2010-10-04 Thread Ritesh Nadhani
Hello This has been making me pull my hair for quite sometime now :) I am trying to use MapperExtension and I have a code like: http://bpaste.net/show/9936/ Basically, I share the model across two apps, so I want one with the extension and one without. Thus the need to use one of the internal

Re: [sqlalchemy] Batch Delete with ORM

2010-10-04 Thread Michael Bayer
On Oct 4, 2010, at 8:06 PM, Mark Erbaugh wrote: Thanks. What is the purpose of SELECT period.realperiod AS period_realperiod FROM period WHERE period.cycle = ? that appears to be generated by the session.query ... call? the delete() and update() methods on Query want to invalidate

Re: [sqlalchemy] Batch Delete with ORM

2010-10-04 Thread Mark Erbaugh
On Oct 4, 2010, at 8:30 PM, Michael Bayer wrote: On Oct 4, 2010, at 8:06 PM, Mark Erbaugh wrote: Thanks. What is the purpose of SELECT period.realperiod AS period_realperiod FROM period WHERE period.cycle = ? that appears to be generated by the session.query ... call? the

Re: [sqlalchemy] reconstruct_instance not being called when adding an extension dynamically

2010-10-04 Thread Ritesh Nadhani
On Mon, Oct 4, 2010 at 5:45 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Oct 4, 2010, at 8:26 PM, Ritesh Nadhani wrote: Hello This has been making me pull my hair for quite sometime now :) I am trying to use MapperExtension and I have a code like: http://bpaste.net/show/9936/