[sqlalchemy] Re: Column order with declarative base and @declared_attr

2011-07-21 Thread Hans-Martin
> The order is determined by the order in which the actual Column constructor > is called, and an ordering token is applied.    When a mixin is used, the > Column is copied from the mixin, but it's likely that the ordering token is > preserved.   You'd declare them on Foo directly without using

Re: [sqlalchemy] Column order with declarative base and @declared_attr

2011-07-21 Thread Michael Bayer
On Jul 21, 2011, at 4:07 PM, Hans-Martin v. Gaudecker wrote: > Hi, > > I am creating a bunch of columns by means of the declared_attr decorator > since many of them contain foreign keys. Similar to the issue in this thread > [1] from a year ago, it seems that the column order is not preserved

[sqlalchemy] Column order with declarative base and @declared_attr

2011-07-21 Thread Hans-Martin v. Gaudecker
Hi, I am creating a bunch of columns by means of the declared_attr decorator since many of them contain foreign keys. Similar to the issue in this thread [1] from a year ago, it seems that the column order is not preserved. To shamelessly borrow the example from that thread, when doing: clas

Re: [sqlalchemy] Problem with class mixin hierarchy in joint table inheritance

2011-07-21 Thread Michael Bayer
On Jul 21, 2011, at 10:48 AM, Michael Bayer wrote: > > On Jul 21, 2011, at 2:11 AM, Fayaz Yusuf Khan wrote: > >> Hi, >> I have this declarative table model: >> http://paste.pound-python.org/show/9857/ > > The short answer is you can't do it that way right now. The "user" and > "timestamp" c

[sqlalchemy] Re: Unexpected IntegrityError when trying to add new related element

2011-07-21 Thread Ben Sizer
On Jul 21, 3:35 pm, Conor wrote: > > It means that there is a Child row already in the database with > parent_id=1234. When you reassign p.children to not include that child, > SQLAlchemy detects that the child object is now an orphan (has no > parent). Based on your cascade rules (cascade="all"),

Re: [sqlalchemy] Problem with class mixin hierarchy in joint table inheritance

2011-07-21 Thread Michael Bayer
On Jul 21, 2011, at 2:11 AM, Fayaz Yusuf Khan wrote: > Hi, > I have this declarative table model: > http://paste.pound-python.org/show/9857/ The short answer is you can't do it that way right now. The "user" and "timestamp" columns of C can't get assigned to the Table by declarative because

Re: [sqlalchemy] Unexpected IntegrityError when trying to add new related element

2011-07-21 Thread Conor
On 07/21/2011 09:20 AM, Ben Sizer wrote: > I have 2 classes: > > Base = declarative_base() > > class Parent(Base): > __tablename__ = 'parent' > id = Column(Integer, primary_key=True) > children = relationship("Child", cascade="all") > > class Child(Base): >

[sqlalchemy] Unexpected IntegrityError when trying to add new related element

2011-07-21 Thread Ben Sizer
I have 2 classes: Base = declarative_base() class Parent(Base): __tablename__ = 'parent' id = Column(Integer, primary_key=True) children = relationship("Child", cascade="all") class Child(Base): __tablename__ = 'child' id = Column(Integer, prim