Re: [sqlalchemy] Possible bug with join condition on self-referential outer joins

2012-02-08 Thread Pau Tallada
Thank you very much! I'll test it ASAP :) 2012/2/8 Michael Bayer mike...@zzzcomputing.com I have good news on this front, in that I've nailed down how this will work, including a patch that gets this basic thing working as a proof of concept. However, the issue of being able to distinguish

Re: [sqlalchemy] Possible bug with join condition on self-referential outer joins

2012-02-08 Thread Pau Tallada
Uhm, the test I attached on previous mail fails using this branch: $ python test_relationships.py Traceback (most recent call last): File test_relationships (1).py, line 53, in module c1 = Company() File string, line 2, in __init__ File

[sqlalchemy] multiple FK constraints and self referential

2012-02-08 Thread cropr
I aam having an issue defining a 2nd foreign key constraint on 2 derived classes of a base class that uses a self referential join. Base class:ContentBase class ContentBase(Base): __tablename__ = 'content' __mapper_args__ = {'polymorphic_on': ctype, 'polymorphic_identity':'contentbase'}

[sqlalchemy] Re: String matching

2012-02-08 Thread yannack
Great, thanks for this, I will definitely play around with this. Lots of great tools and links here! However, I do have a remark for Mike: you suggest ('%' + literal(custom_string) + '%').ilike('%' + MyClass.column + '%') While this probably works for PGSQL (haven't tested though), in sqlite it

Re: [sqlalchemy] Possible bug with join condition on self-referential outer joins

2012-02-08 Thread Michael Bayer
OK, a misunderstanding, the proof of concept is working as of a specific version (rf41aa3ad1da9) - if you've just checked out the branch then you're seeing a refactoring of code which is in flux, and that stack trace is specifically failing on new code that isn't actually doing anything other

[sqlalchemy] A long-lived ORM object

2012-02-08 Thread Michael Hipp
I have an ORM object that gets loaded once during program run and never changes. sess = Session() unchanging = sess.query(Unchanging).get(1) sess.close() # it is now detached I then need to tell other objects about about it, having a many-to-one relationship to 'unchanging': sess1 =

[sqlalchemy] user defined type

2012-02-08 Thread werner
Hi, I am using some custom types which just about work, i.e. I just have an issue when I do this type of query. result = result.filter(db.Drinkinfo.namesandvar.startswith('cloudy')) It throws the following exception, which is due to my custom type not being correctly setup.

Re: [sqlalchemy] multiple FK constraints and self referential

2012-02-08 Thread Michael Bayer
On Feb 8, 2012, at 9:39 AM, cropr wrote: I aam having an issue defining a 2nd foreign key constraint on 2 derived classes of a base class that uses a self referential join. Base class:ContentBase class ContentBase(Base): __tablename__ = 'content' __mapper_args__ =

Re: [sqlalchemy] user defined type

2012-02-08 Thread Michael Bayer
On Feb 8, 2012, at 10:40 AM, werner wrote: Hi, I am using some custom types which just about work, i.e. I just have an issue when I do this type of query. result = result.filter(db.Drinkinfo.namesandvar.startswith('cloudy')) It throws the following exception, which is due to my

Re: [sqlalchemy] A long-lived ORM object

2012-02-08 Thread Michael Bayer
On Feb 8, 2012, at 10:29 AM, Michael Hipp wrote: I have an ORM object that gets loaded once during program run and never changes. sess = Session() unchanging = sess.query(Unchanging).get(1) sess.close() # it is now detached I then need to tell other objects about about it, having

[sqlalchemy] using sqlalchemy with Google app engine

2012-02-08 Thread alonn
I'm trying to deploy an sqlalchemy+ bottle.py web app to google app engine. I saw they also have an sql like backend so I guess sqlalchemy could work with Gae but I'm not sure would It support sqlalchemy from the box? or how should I the application it if needed? I know this was asked before, but

[sqlalchemy] Re: multiple FK constraints and self referential

2012-02-08 Thread cropr
Thanks for the swift reply. Eventually I solved it, by the hint in your answer about the relationshop referring to no column. Replacing parent_id = Column(Integer, ForeignKey('content.id')) in the base class to parent_id = Column(Integer, ForeignKey(id)) made the trick. It is

Re: [sqlalchemy] A long-lived ORM object

2012-02-08 Thread Michael Hipp
On 2012-02-08 9:50 AM, Michael Bayer wrote: unchanging = sess1.merge(unchanging, dont_load=True) Thanks, Michael this seems to do what I need. But I notice in the docs the kwarg appears to be 'load=False'. Am I looking at the wrong thing?

[sqlalchemy] Re: Association proxy: proxy to mapped class instance?

2012-02-08 Thread Dave
Perfect! Works great. Thanks for the help. -Dave On Feb 7, 8:51 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Feb 7, 2012, at 3:31 PM, Dave wrote: I've got a class Keyword that is many to many to itself through a mapped association table. The association table tracks which keyword

Re: [sqlalchemy] A long-lived ORM object

2012-02-08 Thread Michael Bayer
oh right, the name changed at some point, that's correct. On Feb 8, 2012, at 3:07 PM, Michael Hipp wrote: On 2012-02-08 9:50 AM, Michael Bayer wrote: unchanging = sess1.merge(unchanging, dont_load=True) Thanks, Michael this seems to do what I need. But I notice in the docs the kwarg

RE: [sqlalchemy] Re: String matching

2012-02-08 Thread Jackson, Cameron
I haven't been entirely following along with what you and Mike have been talking about, but one final suggestion: If your problem is something to with LIKE only working in one direction, you could always do the first filter in the query, and then filter those results in the other direction in

[sqlalchemy] When creating many-to-many relationship I get: NoReferencedTableError

2012-02-08 Thread Stefan Urbanek
Hi, I am trying to create a simple many-to-many relationship using PostgreSQL in a specific schema ('cards'). I do it like this: class BaseObject(object): id = Column(Integer, primary_key=True) date_created = Column(DateTime) date_modified = Column(DateTime) collection_cards =

RE: [sqlalchemy] When creating many-to-many relationship I get: NoReferencedTableError

2012-02-08 Thread Jackson, Cameron
Have you tried changing the order so that Card is defined before collection_cards? Obviously you're passing 'cards.id' as a string so that the order doesn't matter, but have you tried it anyway? -Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalchemy@googlegroups.com]

[sqlalchemy] Re: When creating many-to-many relationship I get: NoReferencedTableError

2012-02-08 Thread Stefan Urbanek
Yes, I've tried that. It does not help. Btw. isn't the whole thing executed/resolved on base.metadata.create_all(engine)? Stefan On Feb 9, 12:24 am, Jackson, Cameron cameron.jack...@thalesgroup.com.au wrote: Have you tried changing the order so that Card is defined before collection_cards?

Re: [sqlalchemy] When creating many-to-many relationship I get: NoReferencedTableError

2012-02-08 Thread Michael Bayer
On Feb 8, 2012, at 6:06 PM, Stefan Urbanek wrote: Hi, I am trying to create a simple many-to-many relationship using PostgreSQL in a specific schema ('cards'). I do it like this: class BaseObject(object): id = Column(Integer, primary_key=True) date_created = Column(DateTime)

[sqlalchemy] How do I change enum values after previously creating a table?

2012-02-08 Thread Jackson, Cameron
One of my tables used to have something like: role = Column(Enum('user', 'admin', name = User_Roles)) Now I want to change it to: role = Column(Enum('user', 'superuser', name = User_Roles)) But I can't figure out how to change the enum values in the database. I've tried dropping the

Re: [sqlalchemy] How do I change enum values after previously creating a table?

2012-02-08 Thread Conor
On 02/08/2012 07:29 PM, Jackson, Cameron wrote: One of my tables used to have something like: role = Column(Enum('user', 'admin', name = User_Roles)) Now I want to change it to: role = Column(Enum('user', 'superuser', name = User_Roles)) But I can't figure out how to

RE: [sqlalchemy] How do I change enum values after previously creating a table?

2012-02-08 Thread Jackson, Cameron
(Mike: my problem is solved, but please read my final sentence for an enhancement request) I'm guessing the old User_Roles type still exists in the database. You can drop it with DROP TYPE User_Roles. Yes, this is what I figured was happening, I wasn't sure how to get rid of it though

[sqlalchemy] Re: override char() handling

2012-02-08 Thread Victor Olex
Yeah, this will keep coming back as long as people work with schemas, which use fixed length character types (CHAR, NCHAR), which is probably for another 30 years. May I propose an enhancement to String (and as a result to CHAR, NCHAR and Unicode) to take trim=False keyword and effect a TRIM()