[Sqlalchemy-users] Polymorphic mappers and convert_result_value

2006-07-18 Thread Vasily Sulatskov
Hello, I experience some strange behaviour from polymorphic mappers. It seems that convert_result_value doesn't get called for all columns of polymorphic mappers. Here's a modified polymorhpic example from sqlalchemy distribution (also in an attach): =

Re: [Sqlalchemy-users] Set backref attribute on lazy relationship

2006-07-18 Thread Michael Bayer
On Jul 18, 2006, at 11:18 PM, Daniel Miller wrote: > Take a look at this example in the Hibernate documentation: > > http://www.hibernate.org/hib_docs/v3/reference/en/html/example- > parentchild.html#example-parentchild-bidir > > Hibernate does not automatically add child to parent.children when

Re: [Sqlalchemy-users] Set backref attribute on lazy relationship

2006-07-18 Thread Daniel Miller
Michael Bayer wrote: > youre basically saying that Hibernate supports mutation operations > upon instrumented collections, without it needing to load the full > state of those collections from the database. how would this > support the add() method on Set (need to replace an existing item

Re: [Sqlalchemy-users] unexpected foreign key behaviour

2006-07-18 Thread Randall Smith
Michael Bayer wrote: > On Jul 18, 2006, at 5:54 PM, Randall Smith wrote: > > >>SQLError: (IntegrityError) null value in column "project_id" violates >>not-null constraint >> 'UPDATE planreview.documents SET project_id=%(project_id)s WHERE >>documents.id = %(documents_id)s' {'project_id': None,

Re: [Sqlalchemy-users] Set backref attribute on lazy relationship

2006-07-18 Thread Michael Bayer
i think you underestimate how destablizing and complicated this feature would really be. youre basically saying that Hibernate supports mutation operations upon instrumented collections, without it needing to load the full state of those collections from the database. how would this sup

Re: [Sqlalchemy-users] Set backref attribute on lazy relationship

2006-07-18 Thread Daniel Miller
Michael Bayer wrote: > > you might want to try: > > mapper (someclass, sometable, properties = { > 'rels' : relation(someotherclass, lazy=None) > }) > > which will turn off all loading on the "rels" attribute.im not sure > how well thats going to work since it hasnt

Re: [Sqlalchemy-users] Is polymorphic loading with Multiple Table Inheritance broken?

2006-07-18 Thread Michael Bayer
in fact its not supposed to be eager loading, since self-referential eager loads are not supported. set lazy=True to fix this issue. On Jul 18, 2006, at 7:01 PM, Sol wrote: > Michael Bayer wrote: >> for this program, move the "managers" property after the >> compilation of >> the other map

Re: [Sqlalchemy-users] unexpected foreign key behaviour

2006-07-18 Thread Michael Bayer
On Jul 18, 2006, at 5:54 PM, Randall Smith wrote: > > SQLError: (IntegrityError) null value in column "project_id" violates > not-null constraint > 'UPDATE planreview.documents SET project_id=%(project_id)s WHERE > documents.id = %(documents_id)s' {'project_id': None, > 'documents_id': 13} >

Re: [Sqlalchemy-users] Is polymorphic loading with Multiple Table Inheritance broken?

2006-07-18 Thread Sol
Michael Bayer wrote: > for this program, move the "managers" property after the compilation of > the other mappers: > > person_mapper.compile() > person_mapper.add_property('managers', relation(Manager, > secondary=people_managers, lazy=False)) > > this is a workaround for this particul

[Sqlalchemy-users] unexpected foreign key behaviour

2006-07-18 Thread Randall Smith
I'm getting unexpected behavior when deleting a record with a foreign key. I'm using the 0.2.5 rev 1712. When I delete a record that has a private=True attribute in the FK relationship, SA tries to update the record and set the FK to NULL instead of deleting the record. Applicable code. I tr

Re: [Sqlalchemy-users] Is polymorphic loading with Multiple Table Inheritance broken?

2006-07-18 Thread Michael Bayer
for this program, move the "managers" property after the compilation of the other mappers: person_mapper.compile() person_mapper.add_property('managers', relation(Manager, secondary=people_managers, lazy=False)) this is a workaround for this particular issue. On Jul 16, 2006,

Re: [Sqlalchemy-users] Is polymorphic loading with Multiple Table Inheritance broken?

2006-07-18 Thread Michael Bayer
small working test script that uses sqlite. you can post a ticket or send an email to the list. On Jul 18, 2006, at 5:08 PM, Sol wrote: > Hello, > tinkered a little more on the problem but got nowhere. Should i > create a > ticket on the topic? > > Cheers, Sol. > > > Sol wrote: >> Hello agai

Re: [Sqlalchemy-users] Is polymorphic loading with Multiple Table Inheritance broken?

2006-07-18 Thread Sol
Hello, tinkered a little more on the problem but got nowhere. Should i create a ticket on the topic? Cheers, Sol. Sol wrote: > Hello again, > > >>the mapper associated with select_table is not getting compiled. this >>is a product of the simplification to mapper compilation which compiles >>a

Re: [Sqlalchemy-users] How to find out which object causes an exception

2006-07-18 Thread Michael Bayer
On Jul 18, 2006, at 1:12 PM, William K. Volkman wrote: > I agree that this is perhaps more of an application issue however > there is some logic that supports the idea that across multiple > applications the business logic should go into the database. > What I interpret him asking for is basicall

Re: [Sqlalchemy-users] cascade

2006-07-18 Thread Michael Bayer
On Jul 18, 2006, at 4:57 AM, Julien Cigar wrote: > Ok, I will try the association object, it looks better ! > > Another question, I'm using SQLAlchemy with mod_python. That means > that a Python interpreter is loaded in each apache process (in > prefork mode). In my application I use a global

Re: [Sqlalchemy-users] How to find out which object causes an exception

2006-07-18 Thread William K. Volkman
On Tue, 2006-07-18 at 09:32, Michael Bayer wrote: > On Jul 18, 2006, at 9:52 AM, Charles Duffy wrote: > > > Anyhow, as I was saying, it looks like it should be possible to attach > > the object to the exception in Mapper.save_obj() so you can find out > > which object the issue is related to. The

Re: [Sqlalchemy-users] Can't locate property when setting getter/setter functions on an attribute

2006-07-18 Thread Michael Bayer
heres something in rev 1718 you can try: from sqlalchemy import synonym mapper(PropertyClass, table, properties = { '_hash': table.c.hash, 'hash':synonym('_hash') }, ) results = session.query(PropertyClass).select_by(hash="a b") im a little antsy on th

Re: [Sqlalchemy-users] Set backref attribute on lazy relationship

2006-07-18 Thread Michael Bayer
you might want to try: mapper (someclass, sometable, properties = { 'rels' : relation(someotherclass, lazy=None) }) which will turn off all loading on the "rels" attribute.im not sure how well thats going to work since it hasnt been tested ve

Re: [Sqlalchemy-users] How to find out which object causes an exception

2006-07-18 Thread Michael Bayer
On Jul 18, 2006, at 9:52 AM, Charles Duffy wrote: > Anyhow, as I was saying, it looks like it should be possible to attach > the object to the exception in Mapper.save_obj() so you can find out > which object the issue is related to. The component of what you > suggested I have serious concerns a

Re: [Sqlalchemy-users] How to find out which object causes an exception

2006-07-18 Thread Charles Duffy
With regard to the nested transaction suggestion, I was hoping that this would allow an inner transaction to be rolled back after encountering an error, such that the outer transaction could continue (which I understand to be the behavior you're wanting, right?). Also, by segmenting the changes int

Re: [Sqlalchemy-users] How to find out which object causes an exception

2006-07-18 Thread Yuan HOng
On 7/18/06, Charles Duffy <[EMAIL PROTECTED]> wrote: Yuan HOng wrote: > One possibility is to clear the session cache, which however would > mean other valid changes would also be clear out and got lost. > Therefore I would like SA to inform the application which is the > object that caused the c

Re: [Sqlalchemy-users] How to find out which object causes an exception

2006-07-18 Thread Charles Duffy
Yuan HOng wrote: > One possibility is to clear the session cache, which however would > mean other valid changes would also be clear out and got lost. > Therefore I would like SA to inform the application which is the > object that caused the current SQL exception and then remove the > specific obj

Re: [Sqlalchemy-users] cascade

2006-07-18 Thread Julien Cigar
Ok, I will try the association object, it looks better ! Another question, I'm using SQLAlchemy with mod_python. That means that a Python interpreter is loaded in each apache process (in prefork mode). In my application I use a global session object per process (which is not threadsafe, but.. I