[Sqlalchemy-tickets] Issue #4043: sqlite does not support deferred keyword on (unique) constraint (
Brought to you by:
zzzeek
From: Martin B. <iss...@bi...> - 2017-08-11 19:07:15
|
New issue 4043: sqlite does not support deferred keyword on (unique) constraint https://bitbucket.org/zzzeek/sqlalchemy/issues/4043/sqlite-does-not-support-deferred-keyword Martin Babka: When using sqlite and setting ``` #!python class Model(Base): __tablename__ = 'users' id = Column(Integer, primary_key=True) name = Column(String) order = Column(Integer) __table_args__ = (UniqueConstraint('order', name='single_occurrence_of_order', deferrable=True),) ``` then creating the tables throws sqlite's syntax error: ``` #!text sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) near "DEFERRABLE": syntax error [SQL: '\nCREATE TABLE users (\n\tid INTEGER NOT NULL, \n\tname VARCHAR, \n\t"order" INTEGER, \n\tPRIMARY KEY (id), \n\tCONSTRAINT single_occurrence_of_order UNIQUE ("order") DEFERRABLE\n)\n\n'] ``` [Issue 2841](https://bitbucket.org/zzzeek/sqlalchemy/issues/2841) addresses the problem for MySQL, a similar solution may be done in case of sqlite. I could resolve the problem as in [this commit](https://bitbucket.org/zzzeek/sqlalchemy/commits/cf1ac72bca8b0bc28e09cdb4cdf052bcf82e5076). |