0

I am having trouble with what seems like to be with the SqlDelight intellij plugin. I am trying to write the migrations in one place and not use CREATE statements at all inside the .sq files.

This is my setup:

src/main/sqldelight:

├── com
│   └── wtf
│       └── errorrepro
│           └── database
│               └── one.sq
├── migration
│   └── v1.sqm
└── schema

v1.sqm

CREATE TABLE something(
    id INTEGER
);

one.sq

Here is the issue I am getting inside the editor. No code table-related code hinting is available here, generate menu is also blank in this file.

what:
SELECT * FROM something;
              ^^^^^^^^^
              No table found with name something

build.gradle

I am only showing here the relevant sqldelight config, I am using version 1.5.3 (gradle plugin, intellij plugin and dependency are all on the same version).

...

sqldelight {
    MyDatabase {
        packageName = "com.wtf.errorrepro.database"
        deriveSchemaFromMigrations = true
        verifyMigrations = true
    }
}

...

If I run any of the gradle commands, like generateDebugMyDatabaseInterface, the proper queries are generated. So I do not understand why the editor shows the 'No table found with name' error.

I have reinstalled the plugin, updated gradle, did a clean rebuild, invalidated sources ... Nothing seems to solve this.


Edit:

It is even weirder that in case I create a totally separate project Kotlin + Groovy Gradle and set up SqlDelight there, then the code navigation works well. It is only if I create this setup in an Android project (it can be entirely new) when the navigation fails.

andras
  • 3,305
  • 5
  • 30
  • 45
  • But isn't this what the `deriveSchemaFromMigrations` is for? From the docs: https://cashapp.github.io/sqldelight/jvm_h2/gradle/ `Whether or not to use .sqm files as the source of truth for the schema` – andras Feb 24 '22 at 08:57
  • 1
    Haven't worked with this option, so can't help you here. There's more chances to get an answer in [Kotlin slack](https://surveys.jetbrains.com/s3/kotlin-slack-sign-up), **#squarelibraries** channel – Phil Dukhov Feb 24 '22 at 09:01

0 Answers0