Nevermind... my bad. I finally figured out you don't pass a name as the first parameter to a UniqueConstraint.
Sorry..... On Aug 31, 1:57 pm, Kent <jkentbo...@gmail.com> wrote: > Defining an Index() or UniqueConstraint() within a Table(...) adds the > "schema item" to the table. Defining an Index() by passing one or > more columns also adds the Index to the Table. > > However, defining a unique constraint by itself and passing columns > does *not* add the constraint to the corresponding table as with > Index(). > > Is this known? Is it intentional? (It took me a while to figure out > the two behaved differently) > > ############################################## > from sqlalchemy import * > engine = create_engine('sqlite:///', echo=True) > metadata = MetaData(engine) > > ######### > table=Table("table", metadata, > Column("id_a", Unicode(255), primary_key=True), > Column("id_b", Unicode(255)), > Index('id_b'), > UniqueConstraint('id_a','id_b'), > ) > > # passes: > assert len(table.indexes) == 1 > # passes: > assert any(type(a) == UniqueConstraint for a in table.constraints) > > ######### > tableb=Table("tableb", metadata, > Column("id_a", Unicode(255), primary_key=True), > Column("id_b", Unicode(255)), > ) > Index('tablebindex', tableb.c.id_b) > UniqueConstraint('tablebconstraint', tableb.c.id_a, tableb.c.id_b) > > # passes: > assert len(tableb.indexes) == 1 > # fails: > assert any(type(a) == UniqueConstraint for a in tableb.constraints) > ############################################## -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.