On May 11, 2011, at 10:05 AM, Felix Wolfsteller wrote: > > This unique constraint is not enforced, then (rows with same content are > added > to the secondary table).
that's true its simpler and much more efficient to use a primary key or unique constraint on your association table to enforce this, rather than SQLAlchemy, weighed down by the burden of getting a ton of work done as fast as possible in the not exactly fast Python environment, duplicating that effort. > > Thanks for your quick answer and recipe. > > --felix > >> So you'd need to assign association rows an identity and break it into two >> relationships, which means the association object pattern: >> >> http://www.sqlalchemy.org/docs/orm/relationships.html#association-object >> >> however, the association would be more like this: >> >> class Association(Base): >> __tablename__ = 'association' >> id = Column(Integer, primary_key=True) >> left_id = Column(Integer, ForeignKey('left.id')) >> right_id = Column(Integer, ForeignKey('right.id')) >> >>> Probably related pointer from "nickph" in #sqlalchemy on irc (freenode): >>> (10:59:38) nickph: >>> http://hg.sqlalchemy.org/sqlalchemy/file/23be17cf5025/CHANGES >>> (10:59:48) nickph: "Duplicate items in a list-based collection will be >>> maintained"... >>> >>> Enjoy, >>> >>> --felix >>> >>> -- >>> Felix Wolfsteller | ++49 541 335083-783 | http://www.intevation.de/ >>> PGP Key: 39DE0100 >>> Intevation GmbH, Neuer Graben 17, 49074 Osnabrück | AG Osnabrück, HR B >>> 18998 Geschäftsführer: Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver >>> Wagner >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "sqlalchemy" group. To post to this group, send email to >>> [email protected]. To unsubscribe from this group, send email >>> to [email protected]. For more options, visit this >>> group at http://groups.google.com/group/sqlalchemy?hl=en. >>> >>> <data.py> > > > -- > Felix Wolfsteller | ++49 541 335083-783 | http://www.intevation.de/ > PGP Key: 39DE0100 > Intevation GmbH, Neuer Graben 17, 49074 Osnabrück | AG Osnabrück, HR B 18998 > Geschäftsführer: Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver Wagner > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
