cashapp / sqldelight

SQLDelight - Generates typesafe Kotlin APIs from SQL
https://cashapp.github.io/sqldelight/
Apache License 2.0
6.13k stars 513 forks source link

SQL View Class not generated. #3453

Open brucieW opened 2 years ago

brucieW commented 2 years ago

SQLDelight Version

1.5.3

Operating System

Windows 11

Gradle Version

7.1.1

Kotlin Version

1.6.10

Dialect

MySql

AGP Version

No response

Describe the Bug

I am trying to generate an SQL View. Here is the text in the .sq file:

CREATE VIEW dinnerMenuWithDate AS SELECT menu., menuToMenuItemRelation., menuItem.* FROM menuToMenuItemRelation INNER JOIN menu ON date = menu.date AND menu.isLunch = 0 INNER JOIN menuItem ON menuItemId = menuItem.id WHERE menu.date = :date AND menu.menuId = menuToMenuItemRelation.menuId;

getDinnerMenuForDate: SELECT * FROM dinnerMenuWithDate WHERE date = :date;

This compiles cleanly. The reference to this is generated in the database impl file (i.e. An import fro the class is included as well as the interface functions that use this class but the DinnerMenuWithDate class itself is not generated causing an unresolved reference compiler error.

Stacktrace

No response

Gradle Build Script

import org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    val kotlinVersion = "1.6.10"
    kotlin("jvm") version kotlinVersion
    kotlin("kapt") version kotlinVersion
    kotlin("plugin.serialization") version kotlinVersion
    id("org.jetbrains.compose") version "1.1.0"
    id("com.squareup.sqldelight") version "1.5.3"
}

group = "com.aveo"
version = "1.0"

repositories {
    google()
    mavenCentral()
    maven { url = uri("https://jitpack.io") }
    maven { url = uri("https://maven.pkg.jetbrains.space/public/p/compose/dev") }
}

val sqlDelightVersion by extra("1.5.3")

dependencies {
    implementation(compose.desktop.currentOs)
    implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.3")
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4")

    // Module dependencies
    implementation("javax.inject:javax.inject:1")

    // KODEIN
    implementation("org.kodein.di:kodein-di:7.14.0")

    // SQL DElight
    implementation("com.squareup.sqldelight:runtime:$sqlDelightVersion")
    implementation("com.squareup.sqldelight:coroutines-extensions-jvm:$sqlDelightVersion")
    implementation("com.squareup.sqldelight:jdbc-driver:$sqlDelightVersion")
    implementation("mysql:mysql-connector-java:8.0.30")

    implementation("com.zaxxer:HikariCP:5.0.1")

    // Excel
    implementation("org.apache.poi:poi-ooxml:5.2.2")
    implementation("org.apache.poi:poi-ooxml:5.2.2")
    implementation("org.junit.jupiter:junit-jupiter:5.9.0")

    /**
     * Testing Dependencies
     */
    testImplementation("org.mockito:mockito-inline:4.6.1")
    testImplementation("com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0")

    // Mockito Core : Mockito mock objects library core API and implementation
    testImplementation("org.mockito:mockito-core:4.6.1")

    // Expekt : An assertion library for Kotlin
    testImplementation("com.github.theapache64:expekt:1.0.0")

    testImplementation("org.junit.jupiter:junit-jupiter:5.8.1")
    testImplementation("org.junit.jupiter:junit-jupiter:5.8.1")
}

buildscript {
    dependencies {
        classpath("com.android.tools.build:gradle:7.1.1")
        classpath("com.squareup.sqldelight:gradle-plugin:1.5.3")
    }
}

tasks.withType<KotlinCompile> {
    kotlinOptions.jvmTarget = "11"
    kotlinOptions.freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
}

tasks.test {
    useJUnitPlatform()
}

compose.desktop {
    application {
        mainClass = "presentation.MainKt"
        nativeDistributions {
            targetFormats(TargetFormat.Exe)
            outputBaseDir.set(project.buildDir.resolve("distrib"))
            packageName = "Aveo"
            packageVersion = "1.0.0"

            windows {
                packageVersion = "1.0.0"
                exePackageVersion = "1.0.0"
            }
        }
    }
}

sqldelight {
    database("AveoDatabase") {
        packageName = "com.aveo.db"
        sourceFolders = listOf("sqldelight")
        deriveSchemaFromMigrations = true
        dialect = "mysql"
    }
}
hfhbd commented 1 year ago

Hey, could you please publish your tables to create a reproducer?