question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generate interface task fails with "No table found with name"

See original GitHub issue

SQLDelight Version

1.5.3

Operating System

MacOS 11.6.2

Gradle Version

7.2

Kotlin Version

1.6.10

AGP Version

7.1.1

Describe the Bug

Adding verifyMigrations = true to the configuration will make the generate interface task fail with a “No table found with name” for the name of the table I am migrating.

I have a sample repo reproducing the issue here: https://github.com/Orgmir/SQLDelightVerifyOops you can trigger it by running ./gradlew shared:generateCommonMainOopsDatabaseInterface.

No issue with the actual migration, it will work fine at runtime.

Here’s the SqlDelight config:

sqldelight {
    database("OopsDatabase") {
        packageName = "dev.luisramos.data"
        sourceFolders = listOf("sqldelight/oops")
        schemaOutputDirectory = file("src/commonMain/sqldelight/databases/oops")
        verifyMigrations = true
    }
}

And the file structure: Screen Shot 2022-02-21 at 3 10 50 pm

The table file User.sq

CREATE TABLE user(
    id INTEGER PRIMARY KEY,
    email TEXT,
    phoneNumber TEXT
);

The migration file 1.sqm, it removes the email column:

CREATE TEMPORARY TABLE user_tmp(
    id INTEGER PRIMARY KEY,
    phoneNumber TEXT
);

INSERT INTO user_tmp
    SELECT id,phoneNumber
    FROM user;

DROP TABLE user;

CREATE TABLE user(
    id INTEGER PRIMARY KEY,
    phoneNumber TEXT
);

INSERT INTO user
    SELECT id,phoneNumber FROM user_tmp;

DROP TABLE user_tmp;

Stacktrace

➜  SqlDelightVerifyOops ./gradlew shared:generateCommonMainOopsDatabaseInterface

> Configure project :shared
Kotlin Multiplatform Projects are an Alpha feature. See: https://kotlinlang.org/docs/reference/evolution/components-stability.html. To hide this message, add 'kotlin.mpp.stability.nowarn=true' to the Gradle properties.


The following Kotlin source sets were configured but not added to any Kotlin compilation:
 * androidAndroidTestRelease
 * androidTestFixtures
 * androidTestFixturesDebug
 * androidTestFixturesRelease
You can add a source set to a target's compilation by connecting it with the compilation's default source set using 'dependsOn'.
See https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#connecting-source-sets

> Task :shared:generateCommonMainOopsDatabaseInterface FAILED

/Users/luisramos/Developer/SqlDelightVerifyOops/shared/src/commonMain/sqldelight/oops/dev/luisramos/data/1.sqm line 8:9 - No table found with name user
6    INSERT INTO user_tmp
7        SELECT id,phoneNumber
8        FROM user
              ^^^^

/Users/luisramos/Developer/SqlDelightVerifyOops/shared/src/commonMain/sqldelight/oops/dev/luisramos/data/1.sqm line 10:11 - No table found with name user
10    DROP TABLE user
                 ^^^^


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':shared:generateCommonMainOopsDatabaseInterface'.
> 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.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1s
1 actionable task: 1 executed

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
AlecStrongcommented, Feb 22, 2022

it might need to be in the sourceFolder set in gradle, try moving 1.db under sqldelight/oops

0reactions
AlecStrongcommented, Apr 16, 2022

Ah okay. This is because the .db file still needs to be in the source folder. We can probably throw an error if you schema output directory isnt a subdirectory of a source folder.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No tables were found at task initialization" errors for an AWS ...
To resolve this error: 1.FSPMake sure that the tables exist in the source, and weren't deleted before the task started. 2.FSPIf the tables...
Read more >
Spring Data JPA - "No Property Found for Type" Exception
Spring was giving an error 'No property found for type column'. I was looking at the repository and Entity and didn't find anything....
Read more >
Extract an interface refactoring - Visual Studio - Microsoft Learn
Learn how to use the Quick Actions and Refactorings menu to create an interface by using existing members from a class, struct, ...
Read more >
CREATE TASK - Snowflake Documentation
String that specifies the identifier (i.e. name) for the task; ... Snowsight and the classic web interface do not support creating or modifying...
Read more >
Common Issues with the SQL Server Import and Export Wizard
Error 0xc0202049: Data Flow Task 1: Failure inserting into the read-only ... Make sure the tables you want are actually selected (i.e. not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found