[sqlalchemy] Re: Self-Referential Mapping with Base?

2009-01-12 Thread Michael Bayer
yes, it was a bug that declarative wasn't translating the backref() arguments from strings. On Jan 12, 2009, at 10:22 AM, MikeCo wrote: > > Must have been a bug in the default constructor prior to 0.5.0 final. > I got the same error rerunning with earlier version. Strange, I don't > remember n

[sqlalchemy] Re: Self-Referential Mapping with Base?

2009-01-12 Thread MikeCo
Must have been a bug in the default constructor prior to 0.5.0 final. I got the same error rerunning with earlier version. Strange, I don't remember now how I had this running before. Maybe with my own constructor, but not worth igging to find out, it works with final release. On Jan 11, 1:43 pm,

[sqlalchemy] Re: Self-Referential Mapping with Base?

2009-01-11 Thread Darren Govoni
Ahhh, looks like I'm on rc4. Let me try final and see. On Sun, 2009-01-11 at 13:10 -0500, Michael Bayer wrote: > 0.5.0 final ? > > On Jan 11, 2009, at 12:21 PM, Darren Govoni wrote: > > > > > Hi MikeCo, > > I tried your example, and got this error from SA 0.5. > > > > ValueError: need more tha

[sqlalchemy] Re: Self-Referential Mapping with Base?

2009-01-11 Thread Michael Bayer
0.5.0 final ? On Jan 11, 2009, at 12:21 PM, Darren Govoni wrote: > > Hi MikeCo, > I tried your example, and got this error from SA 0.5. > > ValueError: need more than 0 values to unpack > > Darren > > On Fri, 2009-01-09 at 20:33 -0800, MikeCo wrote: >> from sqlalchemy import * >> from sqlalchem

[sqlalchemy] Re: Self-Referential Mapping with Base?

2009-01-11 Thread Darren Govoni
Hi MikeCo, I tried your example, and got this error from SA 0.5. ValueError: need more than 0 values to unpack Darren On Fri, 2009-01-09 at 20:33 -0800, MikeCo wrote: > from sqlalchemy import * > from sqlalchemy.orm import * > from sqlalchemy.ext.declarative import declarative_base > > dbnam

[sqlalchemy] Re: Self-Referential Mapping with Base?

2009-01-10 Thread Darren Govoni
Interesting to know. Appreciate the examples! On Sat, 2009-01-10 at 05:38 -0800, MikeCo wrote: > One thing to notice about ignoring the ids completely. This can > introduce inefficiencies when updating records. In the sample function > tst3() the line > > child.parent = parent > > causes S

[sqlalchemy] Re: Self-Referential Mapping with Base?

2009-01-10 Thread MikeCo
One thing to notice about ignoring the ids completely. This can introduce inefficiencies when updating records. In the sample function tst3() the line child.parent = parent causes SA to read the old parent record to get the attribute child.parent. Changing to: child.id_d = parent.id el

[sqlalchemy] Re: Self-Referential Mapping with Base?

2009-01-09 Thread MikeCo
I spent some time understanding this a little while ago. Here is the construct you need (thanks to Michael Bayer for making it clear for me) # D self referential class D(Base): __tablename__ = 'D' id = Column(Integer, primary_key=True) id_d = Column(Integer, ForeignKey('D.id')) n

[sqlalchemy] Re: Self-Referential Mapping with Base?

2009-01-09 Thread Darren Govoni
Hi, Thanks for the response. I'm still fairly new to SA but am very impressed with this package! I tried a variety of combinations of mappings. If I use just the parent_id,parent it would seem to make sense logically if my children only have one parent. The tables generate fine. But when I try

[sqlalchemy] Re: Self-Referential Mapping with Base?

2009-01-09 Thread Michael Bayer
On Jan 9, 2009, at 7:42 PM, project2501 wrote: > > Hi, > I'm trying to create a mapped class that allows parent/child > relation of itself. I've spent the last 3 hours searching and reading > the other posts on this, but can't get anything to work. > > I'm on 0.5rc4 and just want to declare thi