Index.unique should be only True or False, index=True on Column breaking this

Issue #2825 resolved
Michael Bayer
repo owner created an issue
>>> from sqlalchemy import Table, MetaData, Column, Integer
>>> t1 = Table('t', MetaData(), Column('x', Integer, index=True))
>>> list(t1.indexes)[0](0).unique

--- a/lib/sqlalchemy/sql/
+++ b/lib/sqlalchemy/sql/
@@ -1123,7 +1123,7 @@ class Column(SchemaItem, ColumnClause):
                     "To create indexes with a specific name, create an "
                     "explicit Index object external to the Table.")
             Index(_truncated_label('ix_%s' % self._label),
-                                    self, unique=self.unique)
+                                    self, unique=self.unique if self.unique is not None else False)
         elif self.unique:
             if isinstance(self.unique, util.string_types):
                 raise exc.ArgumentError(

Comments (2)

  1. Log in to comment