Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
manusaurio opened this issue Mar 25, 2023 · 3 comments · Fixed by #4015
Closed
Labels

Comments

@manusaurio
Copy link

manusaurio commented Mar 25, 2023

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

@manusaurio manusaurio added the bug label Mar 25, 2023
@manusaurio manusaurio changed the title Can't generate sqldelight interfaces if fts5 is being used unless typenames are specified Can't generate sqldelight interfaces if fts is being used unless typenames are specified Mar 25, 2023
@AlecKazakova
Copy link
Collaborator

can you also share any labeled queries you have on that table since I think that's what is actually causing the crash

@manusaurio
Copy link
Author

I made an MRE which can be found here. It's a mostly-empty project with a table definition and not much else (build.gradle.kts here). There are no other queries, and it still fails to build:

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

I also ran .\gradlew.bat generateMainDatabaseInterface --stacktrace on a Windows 10 computer and was able to reproduce the error on it as well.

@AlecKazakova
Copy link
Collaborator

perfect, thanks, will take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants