From 3dfcb28ffc3b32b41ab1d028808ca0e650803d01 Mon Sep 17 00:00:00 2001 From: Amjith Ramanujam Date: Mon, 2 Sep 2019 09:13:36 -0700 Subject: [PATCH] Change the escaping to square brackets. --- sqlite_utils/db.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sqlite_utils/db.py b/sqlite_utils/db.py index 6f08ca9..138bf9f 100644 --- a/sqlite_utils/db.py +++ b/sqlite_utils/db.py @@ -713,9 +713,9 @@ class Table(Queryable): def enable_fts(self, columns, fts_version="FTS5", create_triggers=False): "Enables FTS on the specified columns." sql = """ - CREATE VIRTUAL TABLE "{table}_fts" USING {fts_version} ( + CREATE VIRTUAL TABLE [{table}_fts] USING {fts_version} ( {columns}, - content="{table}" + content=[{table}] ); """.format( table=self.name, @@ -729,15 +729,15 @@ class Table(Queryable): old_cols = ", ".join("old.[{}]".format(c) for c in columns) new_cols = ", ".join("new.[{}]".format(c) for c in columns) triggers = """ - CREATE TRIGGER "{table}_ai" AFTER INSERT ON "{table}" BEGIN - INSERT INTO "{table}_fts" (rowid, {columns}) VALUES (new.rowid, {new_cols}); + CREATE TRIGGER [{table}_ai] AFTER INSERT ON [{table}] BEGIN + INSERT INTO [{table}_fts] (rowid, {columns}) VALUES (new.rowid, {new_cols}); END; - CREATE TRIGGER "{table}_ad" AFTER DELETE ON "{table}" BEGIN - INSERT INTO "{table}_fts" ("{table}_fts", rowid, {columns}) VALUES('delete', old.rowid, {old_cols}); + CREATE TRIGGER [{table}_ad] AFTER DELETE ON [{table}] BEGIN + INSERT INTO [{table}_fts] ([{table}_fts], rowid, {columns}) VALUES('delete', old.rowid, {old_cols}); END; - CREATE TRIGGER "{table}_au" AFTER UPDATE ON "{table}" BEGIN - INSERT INTO "{table}_fts" ("{table}_fts", rowid, {columns}) VALUES('delete', old.rowid, {old_cols}); - INSERT INTO "{table}_fts" (rowid, {columns}) VALUES (new.rowid, {new_cols}); + CREATE TRIGGER [{table}_au] AFTER UPDATE ON [{table}] BEGIN + INSERT INTO [{table}_fts] ([{table}_fts], rowid, {columns}) VALUES('delete', old.rowid, {old_cols}); + INSERT INTO [{table}_fts] (rowid, {columns}) VALUES (new.rowid, {new_cols}); END; """.format( table=self.name, @@ -750,8 +750,8 @@ class Table(Queryable): def populate_fts(self, columns): sql = """ - INSERT INTO "{table}_fts" (rowid, {columns}) - SELECT rowid, {columns} FROM "{table}"; + INSERT INTO [{table}_fts] (rowid, {columns}) + SELECT rowid, {columns} FROM [{table}]; """.format( table=self.name, columns=", ".join(columns) )