sqldelight icon indicating copy to clipboard operation
sqldelight copied to clipboard

Use sqlite extensions with sqldelight

Open benjdero opened this issue 2 years ago • 1 comments

SQLDelight Version

1.5.3

Operating System

Linux

Gradle Version

7.3.3

Kotlin Version

1.5.31

AGP Version

7.0.4

Describe the Bug

As an experiment, I've managed to compile the Spellfix1 extension as a dynamic library, load it and use it with the Android low level API (SQLiteOpenHelper, SQLiteDatabase ...)

But now, my real life application in which I want to integrate the spellfix extension, use Sqldelight to manage my Sqlite database. The problem is Sqldelight doesn't recognize the columns name for the tables created by the spellfix and fts extensions:

CREATE VIRTUAL TABLE ft USING fts4(
    name
);

CREATE VIRTUAL TABLE ft_terms USING fts4aux(
    ft
);

CREATE VIRTUAL TABLE demo USING spellfix1;

INSERT INTO demo(word)
SELECT term
FROM ft_terms
WHERE col='*';

SELECT word, rank, distance, langid, score, matchlen
FROM demo
WHERE word MATCH :query;

How can I work around this?

Stacktrace

> Task :app:generateDebugSqlServiceInterface FAILED

/home/me/AndroidStudioProjects/test/app/src/main/sql/com/test/test/Test.sq line 30:17 - No column found with name word
30    INSERT INTO demo(word)
                       ^^^^
31        SELECT term
32        FROM ft_terms
33        WHERE col='*'

/home/me/AndroidStudioProjects/test/app/src/main/sql/com/test/test/Test.sq line 31:11 - No column found with name term
30    INSERT INTO demo(word)
31        SELECT term
                 ^^^^
32        FROM ft_terms
33        WHERE col='*'

/home/me/AndroidStudioProjects/test/app/src/main/sql/com/test/test/Test.sq line 33:10 - No column found with name col
30    INSERT INTO demo(word)
31        SELECT term
32        FROM ft_terms
33        WHERE col='*'
                ^^^

/home/me/AndroidStudioProjects/test/app/src/main/sql/com/test/test/Test.sq line 37:7 - No column found with name word
37    SELECT word, rank, distance, langid, score, matchlen
             ^^^^
38    FROM demo
39    WHERE word MATCH :query

/home/me/AndroidStudioProjects/test/app/src/main/sql/com/test/test/Test.sq line 37:13 - No column found with name rank
37    SELECT word, rank, distance, langid, score, matchlen
                   ^^^^
38    FROM demo
39    WHERE word MATCH :query

/home/me/AndroidStudioProjects/test/app/src/main/sql/com/test/test/Test.sq line 37:19 - No column found with name distance
37    SELECT word, rank, distance, langid, score, matchlen
                         ^^^^^^^^
38    FROM demo
39    WHERE word MATCH :query

/home/me/AndroidStudioProjects/test/app/src/main/sql/com/test/test/Test.sq line 37:29 - No column found with name langid
37    SELECT word, rank, distance, langid, score, matchlen
                                   ^^^^^^
38    FROM demo
39    WHERE word MATCH :query

/home/me/AndroidStudioProjects/test/app/src/main/sql/com/test/test/Test.sq line 37:37 - No column found with name score
37    SELECT word, rank, distance, langid, score, matchlen
                                           ^^^^^
38    FROM demo
39    WHERE word MATCH :query

/home/me/AndroidStudioProjects/test/app/src/main/sql/com/test/test/Test.sq line 37:44 - No column found with name matchlen
37    SELECT word, rank, distance, langid, score, matchlen
                                                  ^^^^^^^^
38    FROM demo
39    WHERE word MATCH :query

/home/me/AndroidStudioProjects/test/app/src/main/sql/com/test/test/Test.sq line 39:6 - No column found with name word
37    SELECT word, rank, distance, langid, score, matchlen
38    FROM demo
39    WHERE word MATCH :query
            ^^^^


Execution failed for task ':app:generateDebugSqlServiceInterface'.
> A failure occurred while executing com.squareup.sqldelight.gradle.SqlDelightTask$GenerateInterfaces
   > Generation failed; see the generator error output for details.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

Gradle Build Script

No response

benjdero avatar Jan 11 '22 10:01 benjdero

you can use the driver APIs to execute raw sql, theres no other workarounds within sqldelight. This is something we plan on adding functionality for but theres no timeline at the moment

AlecKazakova avatar Jan 11 '22 14:01 AlecKazakova