I'm developing a dictionary app, which provides search using FTS table.
The definitions come from a pre-packaged database, which has following schema: (output of .schema
from sqlite3 program on Linux)
sqlite> .open words.db
sqlite> .schema
CREATE TABLE entries
(id INTEGER PRIMARY KEY NOT NULL,
word TEXT NOT NULL COLLATE NOCASE,
wordtype TEXT NOT NULL COLLATE NOCASE,
definition TEXT NOT NULL COLLATE NOCASE);
CREATE INDEX words_index ON entries(id, word);
CREATE VIRTUAL TABLE entriesFts USING FTS4(content='entries', word)
/* entriesFts(word) */;
CREATE TABLE IF NOT EXISTS 'entriesFts_segments'(blockid INTEGER PRIMARY KEY, block BLOB);
CREATE TABLE IF NOT EXISTS 'entriesFts_segdir'(level INTEGER,idx INTEGER,start_block INTEGER,leaves_end_block INTEGER,end_block INTEGER,root BLOB,PRIMARY KEY(level, idx));
CREATE TABLE IF NOT EXISTS 'entriesFts_docsize'(docid INTEGER PRIMARY KEY, size BLOB);
CREATE TABLE IF NOT EXISTS 'entriesFts_stat'(id INTEGER PRIMARY KEY, value BLOB);
And my Entities definations look like these:
@Entity(tableName="entries",
indices = [Index(name = "words_index", value = ["id", "word"])])
data class Word (
@PrimaryKey val id :Int,
@ColumnInfo val word :String,
@ColumnInfo(name = "wordtype") val wordType :String,
@ColumnInfo val definition :String
)
/* Used when displaying list of words */
@Fts4(contentEntity = Word::class)
@Entity(tableName = "entriesFts")
data class WordMinimal (
@PrimaryKey @ColumnInfo(name = "rowid") val id :Int,
@ColumnInfo val word :String
)
It looks to me like the schemas match perfectly, but Room has a different opinion :/
It throws this error in logcat:
java.lang.IllegalStateException: Pre-packaged database has an invalid schema: entriesFts(rawderm.dictionary.en.db.WordMinimal).
Expected:
FtsTableInfo{name='entriesFts', columns=[word], options=[content=`entries`]}
Found:
FtsTableInfo{name='entriesFts', columns=[word], options=[content='entries']}