Fixed issue that omitted the comma between multiple SQLite table extension
clauses, currently ``WITHOUT ROWID`` and ``STRICT``, when both options
:paramref:`.Table.sqlite_with_rowid` and :paramref:`.Table.sqlite_strict`
were configured at their non-default settings at the same time. Pull
request courtesy david-fed.
Fixes: #12368
Closes: #12369
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12369
Pull-request-sha:
3c9ceffe8279f5d961a44e6d468f21881bcbc75c
Change-Id: I1a44fd2d655d0e6eaad8213a360879daca9e4f11
(cherry picked from commit
48ad8c81115bd01d733fe1a4f78c8c30d7c2abbb)
--- /dev/null
+.. change::
+ :tags: bug, sqlite
+ :tickets: 12368
+
+ Fixed issue that omitted the comma between multiple SQLite table extension
+ clauses, currently ``WITH ROWID`` and ``STRICT``, when both options
+ :paramref:`.Table.sqlite_with_rowid` and :paramref:`.Table.sqlite_strict`
+ were configured at their non-default settings at the same time. Pull
+ request courtesy david-fed.
return text
def post_create_table(self, table):
- text = ""
- if table.dialect_options["sqlite"]["with_rowid"] is False:
- text += "\n WITHOUT ROWID"
- if table.dialect_options["sqlite"]["strict"] is True:
- text += "\n STRICT"
- return text
+ table_options = []
+
+ if not table.dialect_options["sqlite"]["with_rowid"]:
+ table_options.append("WITHOUT ROWID")
+
+ if table.dialect_options["sqlite"]["strict"]:
+ table_options.append("STRICT")
+
+ if table_options:
+ return "\n " + ",\n ".join(table_options)
+ else:
+ return ""
class SQLiteTypeCompiler(compiler.GenericTypeCompiler):
"CREATE TABLE atable (id INTEGER) STRICT",
)
+ def test_create_table_without_rowid_strict(self):
+ m = MetaData()
+ table = Table(
+ "atable",
+ m,
+ Column("id", Integer),
+ sqlite_with_rowid=False,
+ sqlite_strict=True,
+ )
+ self.assert_compile(
+ schema.CreateTable(table),
+ "CREATE TABLE atable (id INTEGER) WITHOUT ROWID, STRICT",
+ )
+
class OnConflictDDLTest(fixtures.TestBase, AssertsCompiledSQL):
__dialect__ = sqlite.dialect()