Hi, just for anyone arriving here to save some time: I tried this with 0.5rc4 and the following piece of code
=== from sqlalchemy import types as satypes from sqlalchemy import schema as saschema from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class MasterEntity(Base): __tablename__ = "master" id = saschema.Column(satypes.Integer, primary_key=True) key = saschema.Column(satypes.Unicode(16)) entitytype = saschema.Column(satypes.String(32)) __mapper_args__ = {'polymorphic_on': entitytype, 'polymorphic_identity': 'master'} __table_args__ = ((saschema.UniqueConstraint(entitytype, key),), {}) === and received the error "AttributeError: 'tuple' object has no attribute '_set_parent'". Changing the last line to __table_args__ = (saschema.UniqueConstraint(entitytype, key), {}) (means: removing the tuple) yields KeyError: Column('entitytype', ...) but this (means: put column names into quotes) eventually works: __table_args__ = ( saschema.UniqueConstraint("entitytype", "key"), {} ) Regards, Frank ---------- Forwarded message ---------- From: Michael Bayer <mike...@zzzcomputing.com> Date: Sep 15, 12:51 am Subject: declarative_base and UNIQUE Constraint To: sqlalchemy format is __table_args__ = ((UniqueConstraint(....),), {}) On Sep 14, 2008, at 1:49 PM, GustaV wrote: > How do I create a unique constraint with the declarative plugin > (latest version 0.5) ? > both: > __table_args__ = (UniqueConstraint('region.x', 'region.y'), > {'mysql_engine':'InnoDB'} ) > __table_args__ = (UniqueConstraint(x, y), {'mysql_engine':'InnoDB'} ) > don't work. > Thanks! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---