mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-28 04:44:26 +02:00
Change the escaping to square brackets.
This commit is contained in:
parent
d0658fda27
commit
3dfcb28ffc
1 changed files with 11 additions and 11 deletions
|
|
@ -713,9 +713,9 @@ class Table(Queryable):
|
||||||
def enable_fts(self, columns, fts_version="FTS5", create_triggers=False):
|
def enable_fts(self, columns, fts_version="FTS5", create_triggers=False):
|
||||||
"Enables FTS on the specified columns."
|
"Enables FTS on the specified columns."
|
||||||
sql = """
|
sql = """
|
||||||
CREATE VIRTUAL TABLE "{table}_fts" USING {fts_version} (
|
CREATE VIRTUAL TABLE [{table}_fts] USING {fts_version} (
|
||||||
{columns},
|
{columns},
|
||||||
content="{table}"
|
content=[{table}]
|
||||||
);
|
);
|
||||||
""".format(
|
""".format(
|
||||||
table=self.name,
|
table=self.name,
|
||||||
|
|
@ -729,15 +729,15 @@ class Table(Queryable):
|
||||||
old_cols = ", ".join("old.[{}]".format(c) for c in columns)
|
old_cols = ", ".join("old.[{}]".format(c) for c in columns)
|
||||||
new_cols = ", ".join("new.[{}]".format(c) for c in columns)
|
new_cols = ", ".join("new.[{}]".format(c) for c in columns)
|
||||||
triggers = """
|
triggers = """
|
||||||
CREATE TRIGGER "{table}_ai" AFTER INSERT ON "{table}" BEGIN
|
CREATE TRIGGER [{table}_ai] AFTER INSERT ON [{table}] BEGIN
|
||||||
INSERT INTO "{table}_fts" (rowid, {columns}) VALUES (new.rowid, {new_cols});
|
INSERT INTO [{table}_fts] (rowid, {columns}) VALUES (new.rowid, {new_cols});
|
||||||
END;
|
END;
|
||||||
CREATE TRIGGER "{table}_ad" AFTER DELETE ON "{table}" BEGIN
|
CREATE TRIGGER [{table}_ad] AFTER DELETE ON [{table}] BEGIN
|
||||||
INSERT INTO "{table}_fts" ("{table}_fts", rowid, {columns}) VALUES('delete', old.rowid, {old_cols});
|
INSERT INTO [{table}_fts] ([{table}_fts], rowid, {columns}) VALUES('delete', old.rowid, {old_cols});
|
||||||
END;
|
END;
|
||||||
CREATE TRIGGER "{table}_au" AFTER UPDATE ON "{table}" BEGIN
|
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] ([{table}_fts], rowid, {columns}) VALUES('delete', old.rowid, {old_cols});
|
||||||
INSERT INTO "{table}_fts" (rowid, {columns}) VALUES (new.rowid, {new_cols});
|
INSERT INTO [{table}_fts] (rowid, {columns}) VALUES (new.rowid, {new_cols});
|
||||||
END;
|
END;
|
||||||
""".format(
|
""".format(
|
||||||
table=self.name,
|
table=self.name,
|
||||||
|
|
@ -750,8 +750,8 @@ class Table(Queryable):
|
||||||
|
|
||||||
def populate_fts(self, columns):
|
def populate_fts(self, columns):
|
||||||
sql = """
|
sql = """
|
||||||
INSERT INTO "{table}_fts" (rowid, {columns})
|
INSERT INTO [{table}_fts] (rowid, {columns})
|
||||||
SELECT rowid, {columns} FROM "{table}";
|
SELECT rowid, {columns} FROM [{table}];
|
||||||
""".format(
|
""".format(
|
||||||
table=self.name, columns=", ".join(columns)
|
table=self.name, columns=", ".join(columns)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue