1. Michael Bayer
  2. sqlalchemy

Issues

Issue #2825 resolved

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

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
False



#!diff
--- a/lib/sqlalchemy/sql/schema.py
+++ b/lib/sqlalchemy/sql/schema.py
@@ -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