Application will not compile when a foreign reference uses schema prefix
See original GitHub issueSQLDelight Version
1.5.3
Operating System
macOS Big Sur 11.6.1
Gradle Version
7.3.1
Kotlin Version
1.6.0
AGP Version
No response
Describe the Bug
My postgres database contains a schema called pld1 and within this schema there are two tables Person and Car. Car references Person through a foreign key. The name of the schema is used as a prefix for the tables and foreign key. Application doesn’t compile because of the schema prefix in the REFERENCES statement, even though it is valid sql. Everything works fine if the public schema is used and no schema prefix is used, but this doesn’t satisfy my needs.
Stacktrace
> Task :generateMainTestDatabaseInterface FAILED
line 6:65 - '(', ')', ',', DEFERRABLE, MATCH, NOT or ON expected, got '.'
1 CREATE TABLE pld1.Car
2 (
3 id SERIAL PRIMARY KEY,
4 make VARCHAR(255) NOT NULL,
5 person_id VARCHAR(255) NOT NULL,
6 CONSTRAINT fk_personId FOREIGN KEY(person_id) REFERENCES pld1.Person(id)
^
7 )
Gradle Build Script
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "2.6.1"
id("io.spring.dependency-management") version "1.0.11.RELEASE"
id("com.squareup.sqldelight") version "1.5.3"
kotlin("jvm") version "1.6.0"
kotlin("plugin.spring") version "1.6.0"
}
group = "com.example"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_11
repositories {
google()
mavenCentral()
}
dependencies {
implementation(kotlin("stdlib"))
implementation("com.squareup.sqldelight:gradle-plugin:1.5.3")
implementation("com.squareup.sqldelight:jdbc-driver:1.5.3")
// implementation("org.springframework.boot:spring-boot-starter-data-rest")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
implementation("com.h2database:h2:1.3.148")
implementation("org.postgresql:postgresql:42.1.4")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "11"
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
sqldelight {
database("TestDatabase") {
packageName = "no.testpack"
dialect = "postgresql"
schemaOutputDirectory = file("build/dbs")
sourceFolders = listOf("sqldelight")
deriveSchemaFromMigrations = true
}
linkSqlite = false
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
Remove ns2 as default namespace prefix - java - Stack Overflow
I had one schema importing another, this was causing the problem. The code you posted here did not work directly, but I solved...
Read more >Compiling and Linking STEP Applications - STEP Tools, Inc.
Overview. This chapter covers how to compile and link basic programs, and programs that use C++ classes generated from EXPRESS schemas.
Read more >ALTER SESSION SET CURRENT_SCHEMA - Ask TOM
ALTER SESSION SET CURRENT_SCHEMA I have an application which requires us to change schema's within the application to update a table for various...
Read more >Compile-time Options - SQLite
And the SQLITE_OMIT_PROGRESS_CALLBACK option is only usable by applications that do not use the sqlite3_progress_handler() interface. And so ...
Read more >RFC 6020: YANG - A Data Modeling Language for the ...
References to definitions in the local module MAY use the prefix notation. Since built-in data types do not belong to any module and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
yea we should definitely support this, I don’t think it should be too complex to do since we can just treat the whole string
pld1.Person
as the table nameYep, that’s correct!