Skip to content

Commit

Permalink
Properly propagate the synthesized columns
Browse files Browse the repository at this point in the history
  • Loading branch information
AlecKazakova committed Feb 25, 2019
1 parent bf21f31 commit a5faee9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
Expand Up @@ -19,14 +19,14 @@ internal abstract class CreateTriggerMixin(
if (child is MutatorMixin || child is SqliteExpr) {
val table = tablesAvailable(this).first { it.tableName.name == tableName?.name }.query
if (hasElement(SqliteTypes.INSERT)) {
return listOf(QueryResult(SingleRow(tableName!!, "new"), table.columns))
return listOf(QueryResult(SingleRow(tableName!!, "new"), table.columns, synthesizedColumns = table.synthesizedColumns))
}
if (hasElement(SqliteTypes.UPDATE)) {
return listOf(QueryResult(SingleRow(tableName!!, "new"), table.columns),
QueryResult(SingleRow(tableName!!, "old"), table.columns))
return listOf(QueryResult(SingleRow(tableName!!, "new"), table.columns, synthesizedColumns = table.synthesizedColumns),
QueryResult(SingleRow(tableName!!, "old"), table.columns, synthesizedColumns = table.synthesizedColumns))
}
if (hasElement(SqliteTypes.DELETE)) {
return listOf(QueryResult(SingleRow(tableName!!, "old"), table.columns))
return listOf(QueryResult(SingleRow(tableName!!, "old"), table.columns, synthesizedColumns = table.synthesizedColumns))
}
}
if (child is SqliteColumnName) {
Expand Down
Expand Up @@ -16,7 +16,7 @@ internal abstract class CreateVirtualTableMixin(
SqliteCreateVirtualTableStmt,
TableElement {
override fun tableExposed(): LazyQuery {
val synthesizedColumns = if (moduleName?.text?.startsWith("fts") == true) {
val synthesizedColumns = if (moduleName?.text?.startsWith(prefix ="fts", ignoreCase = true) == true) {
listOf(
SynthesizedColumn(
table = this,
Expand Down
18 changes: 18 additions & 0 deletions core/src/test/fixtures/create-trigger-docid/Test.s
@@ -0,0 +1,18 @@
CREATE TABLE task
(
id TEXT NOT NULL,
title TEXT NOT NULL,
description TEXT,
completed INTEGER NOT NULL,
PRIMARY KEY(id)
);

CREATE VIRTUAL TABLE task_fts USING FTS4(title TEXT NOT NULL, description TEXT, content=task);

CREATE TRIGGER content_sync_task_fts_BEFORE_UPDATE
BEFORE UPDATE ON task
BEGIN
DELETE
FROM task_fts
WHERE docid=old.rowid;
END;

0 comments on commit a5faee9

Please sign in to comment.