sqldelight

SQLDelight FTS5 insert trouble


I created a table in DBBrowser:

CREATE VIRTUAL TABLE IF NOT EXISTS Students USING FTS5
(
    GroupId          UNINDEXED,
    StudentName
);

and insert values to it. After that I add DB with this table to my project.

It is declaration of this table in sqldelight .sq file:

CREATE VIRTUAL TABLE IF NOT EXISTS Students USING FTS5
(
    GroupId          INTEGER AS Int,
    StudentName      TEXT,
    rank             REAL
);

I need to explicit declare rank because I want to apply HAVING MIN(rank) for it when SELECT from table (otherwise it is not compile), but when I trying to insert values in table like that:

insert:
INSERT INTO Students VALUES (?,?);

I receive an error:

Unexpected number of values being inserted. found: 2 expected: 3

If I do like that:

insert:
INSERT INTO Students VALUES (?,?,?);

I receive an exception:

SQLiteException - table Students has 2 columns but 3 values were supplied (code 1): , while compiling: INSERT INTO Students VALUES (?,?,?)

How I can perform insert? Or maybe I can apply HAVING MIN(rank) without explicit declare?


Solution

  • does

    insert:
    INSERT INTO Students(GroupId, StudentName) VALUES (?,?);
    

    work?