Re: [sqlalchemy] SQLAlchemy 0.9.1 released

2014-01-08 Thread Michael Bayer
On Jan 8, 2014, at 2:39 AM, limodou limo...@gmail.com wrote: On Wed, Jan 8, 2014 at 3:31 PM, Wichert Akkerman wich...@wiggy.net wrote: On 08 Jan 2014, at 01:26, limodou limo...@gmail.com wrote: But I don't know why make this decision. Because where NULL will get nothing. And in

Re: [sqlalchemy] SQLAlchemy 0.9.1 released

2014-01-08 Thread limodou
“WHERE NULL” is not valid, that’s true; hence neither is select.where(None) anymore, which is what would happen above if “conditions” were empty (and if conditions is guaranteed not empty, you could say “cond = conditions[0]; for c in conditions[1:]:…” ) The change includes that it’s safe

[sqlalchemy] Using flask-sqlalchemy BaseQuery and Pagination with multiple tables.

2014-01-08 Thread Mark S
Hi I can successfully use pagination with the following - mydata=Article.query.filter(Article.author_id==User.id).filter(User.id==g.user.id).paginate(page, POSTS_PER_PAGE, False) However, I need to fetch columns from multiple tables. In that case how can I modify the code above in order to

Re: [sqlalchemy] SQLAlchemy 0.9.1 released

2014-01-08 Thread Michael Bayer
sorry, this should read: Therefore, your script cannot work in either 0.8 or 0.9, unless you fix it as follows, in which case it works the same in both versions: def my_select(conditions): cond = None for c in conditions: cond = c cond stmt = select([column(‘x’)]) if

Re: [sqlalchemy] SQLAlchemy 0.9.1 released

2014-01-08 Thread Michael Bayer
On Jan 8, 2014, at 7:54 AM, limodou limo...@gmail.com wrote: I think there are two things here: 1. Should None be converted to NULL when deal with condition None or and_(condition, None) 2. How to combine multiple condition into one condition with and_ And I think the second question

Re: [sqlalchemy] SQLAlchemy 0.9.1 released

2014-01-08 Thread Michael Bayer
geez..its 10 degrees here, sorry, just scratch that first case, it has to be like this to be fully compatible both ways: def my_select(conditions): stmt = select([column('x')]) if conditions: stmt = stmt.where(and_(*conditions)) return stmt “cond None” was never any kind

Re: [sqlalchemy] SQLAlchemy 0.9.1 released

2014-01-08 Thread Michael Bayer
a new section has been added as the first “Core Behavioral Change”: http://sqlalchemy.readthedocs.org/en/rel_0_9/changelog/migration_09.html#none-can-no-longer-be-used-as-a-partial-and-constructor On Jan 8, 2014, at 11:27 AM, Michael Bayer mike...@zzzcomputing.com wrote: geez..its 10

Re: [sqlalchemy] SQLAlchemy 0.9.1 released

2014-01-08 Thread Claudio Freire
Typo: when condition is non-empty should be when conditionS is non-empty On Wed, Jan 8, 2014 at 1:53 PM, Michael Bayer mike...@zzzcomputing.com wrote: a new section has been added as the first “Core Behavioral Change”:

Re: [sqlalchemy] SQLAlchemy 0.9.1 released

2014-01-08 Thread Michael Bayer
yeah…plus there’s no need for a “None” check when true() is used. I’m supposed to be napping right now, this is the problem On Jan 8, 2014, at 12:01 PM, Claudio Freire klaussfre...@gmail.com wrote: Typo: when condition is non-empty should be when conditionS is non-empty On

Re: [sqlalchemy] Using flask-sqlalchemy BaseQuery and Pagination with multiple tables.

2014-01-08 Thread Simon King
On Wed, Jan 8, 2014 at 3:37 PM, Mark S dbs...@gmail.com wrote: Hi I can successfully use pagination with the following - mydata=Article.query.filter(Article.author_id==User.id).filter(User.id==g.user.id).paginate(page, POSTS_PER_PAGE, False) However, I need to fetch columns from multiple

[sqlalchemy] AssertionError When Removing Children For Association Object

2014-01-08 Thread Russell Holloway
Hello all, I keep hitting an assertion error, Dependency Rule Tried To Blank Out Primary Key... when trying to remove all children using an association object. My situation seems very similar to https://groups.google.com/forum/#!topic/sqlalchemy/3g4__pFHZTs However, based on Michaels

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

2014-01-08 Thread Michael Bayer
On Jan 8, 2014, at 5:41 PM, Russell Holloway russ.d.hollo...@gmail.com wrote: Hello all, I keep hitting an assertion error, Dependency Rule Tried To Blank Out Primary Key... when trying to remove all children using an association object. My situation seems very similar to

[sqlalchemy] Inverse the mapping in a composite association proxy

2014-01-08 Thread Brian Findlay
Hi, all. I've been trying to modify the example of a composite association proxy (http://www.sqlalchemy.org/docs/orm/extensions/associationproxy.html#composite-association-proxies) to fit my needs. In the documentation example, there is a User object, a Keyword object, and a UserKeyword

Re: [sqlalchemy] Inverse the mapping in a composite association proxy

2014-01-08 Thread Michael Bayer
OK well to do it exactly the way the example does it, each time we create a UserCourse, it will also create a Course. That’s pretty simple, we use two association proxies, one for User.courses and the other for UserCourse.course, mappings are like this: class User(Base): __tablename__ =

Re: [sqlalchemy] Inverse the mapping in a composite association proxy

2014-01-08 Thread Brian Findlay
Well, if it isn't the man himself. Mike, you're awesome -- thanks for the hand-holding. Thanks for reading into my use case and providing the second example. Also, thanks for the thorough documentation (on SQLAlchemy and Mako). This would be infinitely more difficult without it. On another

Re: [sqlalchemy] SQLAlchemy 0.9.1 released

2014-01-08 Thread limodou
On Thu, Jan 9, 2014 at 12:20 AM, Michael Bayer mike...@zzzcomputing.comwrote: On Jan 8, 2014, at 7:54 AM, limodou limo...@gmail.com wrote: I think there are two things here: 1. Should None be converted to NULL when deal with condition None or and_(condition, None) 2. How to combine

Re: [sqlalchemy] Inverse the mapping in a composite association proxy

2014-01-08 Thread Brian Findlay
Mike, It took a few hours to wrap my head around your work and adapt it to my actual use case, but it's working great now...except for a particular case when used with templates. Basically, I'm querying for relevant courses and then iterating over the results to construct a form for grade