Re: [sqlalchemy] AssertionError When Removing Children For Association Object

2014-01-09 Thread Russell Holloway
you need to put a cascade rule on Page.user_relationships, such that when you remove a Page_to_User from the collection, it’s marked as deleted, instead of SQLAlchemy setting the page_id foreign key to NULL, which is invalid here b.c. that column is part of the primary key (and hence the

Re: [sqlalchemy] SQLAlchemy 0.9.1 released

2014-01-09 Thread Michael Bayer
On Jan 8, 2014, at 8:55 PM, limodou limo...@gmail.com wrote: Yes, I saw the code about 0.8.X and 0.9.1, the None convertion are the same. But difference between them is in AND process. So this inconsistent that you mean it's a bug in 0.8? it’s a bug in 0.8, yes. I think raise

Re: [sqlalchemy] AssertionError When Removing Children For Association Object

2014-01-09 Thread Michael Bayer
On Jan 9, 2014, at 10:02 AM, Russell Holloway russ.d.hollo...@gmail.com wrote: you need to put a cascade rule on Page.user_relationships, such that when you remove a Page_to_User from the collection, it’s marked as deleted, instead of SQLAlchemy setting the page_id foreign key to NULL,

Re: [sqlalchemy] AssertionError When Removing Children For Association Object

2014-01-09 Thread Russell Holloway
OK so, you have: Page.user_relationships - collection of PageToUser PageToUser - single User then, you are saying : some_page.user_relationships = [] session.flush() What SQL would you expect this to produce? After a flush, what would the rows in your page_to_user table look

[sqlalchemy] Multiple inheritance issue

2014-01-09 Thread Enrico Bottani
Hello guys, I'm building a web service to provide data to our SDK and I'm facing a wired problem. I have created 4 different models for my needs, a base class that is called *Unit*, two derivatives from the base class *VideoUnit*, *QuestionUnit*, and the last class is a derivative of both

Re: [sqlalchemy] Anybody have twophase/zope.sqlalchemy/MySQL working?

2014-01-09 Thread Jeff Dairiki
Thank you for the reply! Sorry for the delayed response. (Holidays.) On Mon, Dec 23, 2013 at 11:52:25PM -0800, Laurence Rowe wrote: On Thursday, 12 December 2013 16:30:59 UTC-8, Jeff Dairiki wrote: Do you understand why the datamanager is finding the SessionTransaction and using that

Re: [sqlalchemy] AssertionError When Removing Children For Association Object

2014-01-09 Thread Michael Bayer
On Jan 9, 2014, at 10:31 AM, Russell Holloway russ.d.hollo...@gmail.com wrote: OK so, you have: Page.user_relationships - collection of PageToUser PageToUser - single User then, you are saying : some_page.user_relationships = [] session.flush() What SQL would you expect this

Re: [sqlalchemy] Multiple inheritance issue

2014-01-09 Thread Michael Bayer
On Jan 9, 2014, at 11:32 AM, Enrico Bottani bei...@mac.com wrote: Hello guys, I'm building a web service to provide data to our SDK and I'm facing a wired problem. I have created 4 different models for my needs, a base class that is called Unit, two derivatives from the base class

[sqlalchemy] Integrity errors in foreign key with nullable=False in a large hierarchy

2014-01-09 Thread Paul Moore
The following is a stripped down example of my app, that does NOT show the problem: from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import relationship, backref, sessionmaker from sqlalchemy import Column, Integer, String, ForeignKey from sqlalchemy import

Re: [sqlalchemy] Integrity errors in foreign key with nullable=False in a large hierarchy

2014-01-09 Thread Michael Bayer
On Jan 9, 2014, at 4:02 PM, Paul Moore p.f.mo...@gmail.com wrote: The real app is basically just a lot more complex (releases have 4 child lists like urls, my example adds multiple objects in each list. The app fails with an integrity error because a url has a null request_id. In actual

Re: [sqlalchemy] Integrity errors in foreign key with nullable=False in a large hierarchy

2014-01-09 Thread Paul Moore
On Thursday, 9 January 2014 21:27:06 UTC, Michael Bayer wrote: I think one of the error tracebacks (sorry, I lost them in other output) mentioned autoflush - could the ORM be trying to flush bits of the hierarchy before it's complete? Is there a better fix than removing the nullable=False

[sqlalchemy] SQLAlchemy not executing query

2014-01-09 Thread Sylvester Steele
Hi, I am using SQLAlchemy version 0.7.6 with pyodbc to connect to MSSQL 2012. Currently I am using SQLAlchemy only for its connection pooling etc. So, at the moment I only use the engine.execute function to execute string queries. Weirdly, the following query seems to have no effect at

[sqlalchemy] Why ORM objects in a session expire immediately after a failure in flush?

2014-01-09 Thread Weikai Xie
Hi, folks, I observed that it seems all ORM objects in a session will expire immediately if there is a failure in session.flush(). I was wondering what's the rationale behind this behavior. Following is an artificial web application code to illustrate the idea: def PUT(): #

Re: [sqlalchemy] SQLAlchemy not executing query

2014-01-09 Thread Michael Bayer
The statement is likely being invoked but is in a transaction that isn’t getting committed (assuming you’re using commit() with pyodbc). SQLAlchemy has an “autocommit” feature that by default looks for SQL strings that indicate a COMMIT should occur. So in this case you should make sure

Re: [sqlalchemy] Why ORM objects in a session expire immediately after a failure in flush?

2014-01-09 Thread Michael Bayer
On Jan 9, 2014, at 7:17 PM, Weikai Xie xiewei...@gmail.com wrote: Hi, folks, I observed that it seems all ORM objects in a session will expire immediately if there is a failure in session.flush(). I was wondering what's the rationale behind this behavior. Following is an artificial