Skip to content

Can't generate sqldelight interfaces if fts is being used unless typenames are specified #4001

@manusaurio

Description

@manusaurio

SQLDelight Version

2.0.0-alpha05

Operating System

Arch Linux x86_64 (kernel: 6.2.6-zen1-1-zen)

Gradle Version

Gradle 8.0.2

Kotlin Version

1.6.10

Dialect

sqlite-3-38-dialect

AGP Version

No response

Describe the Bug

./gradlew run generateMainDatabaseInterface --stacktrace crashes trying to build at following line

CREATE VIRTUAL TABLE myftstable USING fts5(something, nice);

These work just fine, though:

CREATE VIRTUAL TABLE myftstable USING fts5(something TEXT, nice TEXT);
CREATE VIRTUAL TABLE myftstable2 USING fts5(something INTEGER, nice TEXT);
CREATE VIRTUAL TABLE myftstable3 USING fts5(something INTEGER, nice INTEGER UNINDEXED);

yet this one doesn't:

CREATE VIRTUAL TABLE myftstable4 USING fts5(something INTEGER, nice UNINDEXED);

So it seems it crashes every time unless every column has a specified typename. This happens regardless of the fts version being used. Oddly enough, the docs for fts5 state:

It is an error to add types, constraints or PRIMARY KEY declarations to a CREATE VIRTUAL TABLE statement used to create an FTS5 table.

And the ones for fts3 and 4 say:

If column names are explicitly provided for the FTS table as part of the CREATE VIRTUAL TABLE statement, then a datatype name may be optionally specified for each column. This is pure syntactic sugar, the supplied typenames are not used by FTS or the SQLite core for any purpose.

Stacktrace

Caused by: java.lang.StackOverflowError
        at com.intellij.openapi.progress.impl.CoreProgressManager.isInNonCancelableSection(CoreProgressManager.java:774)
        at com.intellij.openapi.progress.impl.CoreProgressManager.doCheckCanceled(CoreProgressManager.java:134)
        at com.intellij.openapi.progress.ProgressManager.checkCanceled(ProgressManager.java:211)
        at com.intellij.openapi.progress.ProgressIndicatorProvider.checkCanceled(ProgressIndicatorProvider.java:23)
        at com.intellij.psi.impl.source.tree.CompositeElement.getPsi(CompositeElement.java:687)
        at com.intellij.psi.impl.source.SourceTreeToPsiMap.treeElementToPsi(SourceTreeToPsiMap.java:16)
        at com.intellij.psi.impl.source.tree.SharedImplUtil.getParent(SharedImplUtil.java:33)
        at com.intellij.extapi.psi.ASTWrapperPsiElement.getParent(ASTWrapperPsiElement.java:19)
        at com.alecstrong.sql.psi.core.psi.SqlColumnReference.unsafeResolve$core(SqlColumnReference.kt:33)
        at com.alecstrong.sql.psi.core.psi.SqlColumnReference$resolved$1.invoke(SqlColumnReference.kt:22)
        at com.alecstrong.sql.psi.core.psi.SqlColumnReference$resolved$1.invoke(SqlColumnReference.kt:20)
        at com.alecstrong.sql.psi.core.ModifiableFileLazy.forFile(ModifiableFileLazy.kt:22)
        at com.alecstrong.sql.psi.core.psi.SqlColumnReference.resolve(SqlColumnReference.kt:28)
        at app.cash.sqldelight.core.lang.util.ColumnDefSourceKt.columnDefSource(ColumnDefSource.kt:11)

Gradle Build Script

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions