[sqlalchemy] Polymorphic concrete inheritance question

2008-12-03 Thread Gaetan de Menten
Hello all, I've been playing a bit with polymorphic concrete inheritance, and noticed that when you have several levels of polymorphic loading (ie my child class is also a parent class which I want to load polymorphically), the query for the top-level class includes the child polymorphic join

[sqlalchemy] Re: Polymorphic concrete inheritance question

2008-12-03 Thread az
hm i had not run my tests for quite a while.. this seems recent thing. lets see if i can dig anything of help... nothing much, one side works, another not at all. one of my set of inheritance tests (direct over sa, A-B) is ok. the other one (over dbcook) fails completely, even for A-B

[sqlalchemy] Re: inferring object class/table directly

2008-12-03 Thread rdmurray
On Tue, 2 Dec 2008 at 23:21, Faheem Mitha wrote: Yes, I was looking for this, and printed out obj.__dict__ but didn't see it there. A dictionary of attributes is very useful in theory, but doesn't always seem to have all attributes. Is this documented anywhere? Try dir(obj). You'll see it

[sqlalchemy] Re: Polymorphic concrete inheritance question

2008-12-03 Thread Michael Bayer
um yeah, actually this behavior is affecting all multi-level usage of polymorphic_union. So, while polymorphic_union is quite obviously (since nobody has noticed this pretty glaring issue) on the decline in the 0.5 series, this is quite severe and ill try to have a look at it today. On

[sqlalchemy] Re: Polymorphic concrete inheritance question

2008-12-03 Thread Gaetan de Menten
On Wed, Dec 3, 2008 at 15:03, Michael Bayer [EMAIL PROTECTED] wrote: um yeah, actually this behavior is affecting all multi-level usage of polymorphic_union. So, while polymorphic_union is quite obviously (since nobody has noticed this pretty glaring issue) on the decline in the 0.5

[sqlalchemy] Re: Polymorphic concrete inheritance question

2008-12-03 Thread Michael Bayer
this ones big, i can handle it. the attached patch makes your case work, but the problem represented here still makes itself apparent in other ways and I havent strength tested this patch. you might want to see if this patch works in all of your test cases.

[sqlalchemy] relation join problem

2008-12-03 Thread Dom
Hi i tried the following example, but i cant get the join to work: CREATE TABLE product ( idINTEGER, price NUMERIC(15,2) NOT NULL, PRIMARY KEY(id) ); CREATE TABLE i18n_product ( id INTEGER, lang VARCHAR(2),

[sqlalchemy] Re: Polymorphic concrete inheritance question

2008-12-03 Thread Gaetan de Menten
On Wed, Dec 3, 2008 at 16:04, Michael Bayer [EMAIL PROTECTED] wrote: this ones big, i can handle it. the attached patch makes your case work, but the problem represented here still makes itself apparent in other ways and I havent strength tested this patch. you might want to see if this

[sqlalchemy] Re: New instance ExtraStat with identity key (...) conflicts with persistent instance ExtraStat

2008-12-03 Thread Doug Farrell
I've met so few other Farrells, maybe we ARE related!! Get it, related, in a SqlAlchemy group. Oh man I'm such a geek!! -Original Message- From: sqlalchemy@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Bob Sent: Tuesday, December 02, 2008 9:00 AM To:

[sqlalchemy] removing instrumentation from a mapped object

2008-12-03 Thread Simon
Hi there, is there any canonical way of removing all SQAlchemy instrumentation from a mapped object? I'm trying to feed a complex mapped class instance through PyAMF (which serializes objects to be read in Adobe Flash). This works fine for scalar attributes but not for collections, e.g. a

[sqlalchemy] Re: Polymorphic concrete inheritance question

2008-12-03 Thread Michael Bayer
it needed some more work. the final version of this fix is in r5412. On Dec 3, 2008, at 10:49 AM, Gaetan de Menten wrote: On Wed, Dec 3, 2008 at 16:04, Michael Bayer [EMAIL PROTECTED] wrote: this ones big, i can handle it. the attached patch makes your case work, but the problem

[sqlalchemy] Re: removing instrumentation from a mapped object

2008-12-03 Thread Simon
On 3 Dez., 18:32, Michael Bayer [EMAIL PROTECTED] wrote: I would also posit that PyAMF's behavior might be inappropriate in   this case.  InstrumentedList is a subclass of list so I don't   immediately see why it would treat it differently. Upon further inspection, this was exactly the case.

[sqlalchemy] SQLAlchemy Sphinx Documentation Preview

2008-12-03 Thread Michael Bayer
We've created a new branch and are in the process of migrating all of our documentation over to Sphinx. The process has gone well and we have a working demo of the full system online. By converting to Sphinx, we get the huge advantage of being on a standardized platform that everyone

[sqlalchemy] Re: relation join problem

2008-12-03 Thread Simon
That would be desc = session.query(I18Product).filter_by(id=1183, lang=en).one() The Problem with your query is that you query() for Product, not for I18NProduct, so regardless of and filter and join functions you specify, you will always receice Product objects. Think of query (Product) as a

[sqlalchemy] Abstract base class

2008-12-03 Thread Guillaume
Hello, is there a way with the ORM layer to have abstract base class like in django ? http://docs.djangoproject.com/en/dev/topics/db/models/#abstract-base- classes Another somehow related question is there any plan for declarative base to support inheritance ala django ? Regards, Guillaume

[sqlalchemy] Re: inferring object class/table directly

2008-12-03 Thread Faheem Mitha
On Wed, 3 Dec 2008 08:58:42 -0500 (EST), [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On Tue, 2 Dec 2008 at 23:21, Faheem Mitha wrote: Yes, I was looking for this, and printed out obj.__dict__ but didn't see it there. A dictionary of attributes is very useful in theory, but doesn't always seem

[sqlalchemy] Re: Abstract base class

2008-12-03 Thread Michael Bayer
On Dec 3, 2008, at 1:26 PM, Guillaume wrote: Hello, is there a way with the ORM layer to have abstract base class like in django ? http://docs.djangoproject.com/en/dev/topics/db/models/#abstract-base- classes sure, just pass along cls=MyBaseClass along to declarative_base(). You can

[sqlalchemy] Re: Polymorphic concrete inheritance question

2008-12-03 Thread az
this is still there:   File sqlalchemy/orm/mapper.py, line 168, in __init__     self.with_polymorphic[1] = self.with_polymorphic[1].alias() TypeError: 'tuple' object does not support item assignment also, related question: once there is A-B-C, concrete, how u'd get some A by id?

[sqlalchemy] Re: Polymorphic concrete inheritance question

2008-12-03 Thread az
and maybe related: def query_by_id( klas, idname, oid, .): q = session.query( klas).filter_by( **{idname: oid}) # filter by atype for concrete m = class_mapper( klas) concrete = bool( m.with_polymorphic[1] ) if concrete: q= q.filter( m.polymorphic_on ==

[sqlalchemy] Re: Polymorphic concrete inheritance question

2008-12-03 Thread Michael Bayer
thats strange, i dont suppose you could send me how you're setting up that polymorphic union On Dec 3, 2008, at 3:05 PM, [EMAIL PROTECTED] wrote: and maybe related: def query_by_id( klas, idname, oid, .): q = session.query( klas).filter_by( **{idname: oid}) # filter by atype

[sqlalchemy] Re: Polymorphic concrete inheritance question

2008-12-03 Thread az
can i... maybe something like table_A = Table( 'A', meta, Column( 'name', String(length=200, ), ), Column( 'db_id', primary_key= True, type_= Integer, ), ) table_B = Table( 'B', meta, Column( 'dataB', String(length=200 ),

[sqlalchemy] Re: Polymorphic concrete inheritance question

2008-12-03 Thread az
this is still there: File sqlalchemy/orm/mapper.py, line 168, in __init__ self.with_polymorphic[1] = self.with_polymorphic[1].alias() TypeError: 'tuple' object does not support item assignment try mapping to something that is already an alias() (this would lend insight into your

[sqlalchemy] I can replace an object with another in python, by changing the object dict to the other object dict. How does it settle with sqlalchemy? Does it works when another mapped object poin

2008-12-03 Thread [EMAIL PROTECTED]
I wrote it on usage reciepts, but no one answered yet. The reason I'm doing so, is to solve the following problem: I have an object that is compounded from the fields - obj_id, num1, num2, num3. obj_id is my primary key. I want to create a save method for the object's class, that will do the

[sqlalchemy] Re: replace an object.dict with another

2008-12-03 Thread az
so u'd get two objects sharing same dict, and changin one will break the other, in a hideous way. better copy stuff one by one, or invent some other way. On Wednesday 03 December 2008 22:47:34 [EMAIL PROTECTED] wrote: I wrote it on usage reciepts, but no one answered yet. The reason I'm

[sqlalchemy] Re: I can replace an object with another in python, by changing the object dict to the other object dict. How does it settle with sqlalchemy? Does it works when another mapped object

2008-12-03 Thread Michael Bayer
SQLAlchemy instruments classes using an event-based system that intercepts all setattribute and collection mutation operations, and logs these events as things to be reconciled when the Session is flushed. Additionally, the __dict__ of the object itself is referenced by the

[sqlalchemy] Re: Polymorphic concrete inheritance question

2008-12-03 Thread Michael Bayer
On Dec 3, 2008, at 3:45 PM, [EMAIL PROTECTED] wrote: okay, then i get this as answer to my other question - so concrete polymorhism relations/get()/identity on top of it are blue_sky. that's okay - just put a line about it in the docs. dbcook is throwing warnings about it since long time.

[sqlalchemy] Re: Polymorphic concrete inheritance question

2008-12-03 Thread az
On Wednesday 03 December 2008 23:28:01 Michael Bayer wrote: On Dec 3, 2008, at 3:45 PM, [EMAIL PROTECTED] wrote: okay, then i get this as answer to my other question - so concrete polymorhism relations/get()/identity on top of it are blue_sky. that's okay - just put a line about it in the

[sqlalchemy] Re: Polymorphic concrete inheritance question

2008-12-03 Thread Michael Bayer
On Dec 3, 2008, at 5:15 PM, [EMAIL PROTECTED] wrote: On Wednesday 03 December 2008 23:28:01 Michael Bayer wrote: On Dec 3, 2008, at 3:45 PM, [EMAIL PROTECTED] wrote: okay, then i get this as answer to my other question - so concrete polymorhism relations/get()/identity on top of it are

[sqlalchemy] Re: I can replace an object with another in python, by changing the object dict to the other object dict. How does it settle with sqlalchemy? Does it works when another mapped object

2008-12-03 Thread kobi...@gmail.com
A. Thanks for this great idea. From your suggestion, I realize that if I am going to use the new method, than I must enforce my __new__ (and __init__) to get all the unique fields as arguments. Then, if the object already exists in the db to return it, and otherwise save the new object. An

[sqlalchemy] Re: I can replace an object with another in python, by changing the object dict to the other object dict. How does it settle with sqlalchemy? Does it works when another mapped object

2008-12-03 Thread Michael Bayer
On Dec 3, 2008, at 6:39 PM, [EMAIL PROTECTED] wrote: B. So I can settle with a merge() method that returns an object. I think it's the only solution (beside forcing them to work with saving to the db). Actually, it's not too bad. But it's also not easy, I tell you, to write such a