sqldelight
sqldelight copied to clipboard
False positive in SchemaNeedsMigrationInspection
SQLDelight Version
2.0.0-alpha02
IDE Version
AS B
Dialect
SQLite
Describe the Bug
I have the following table:
CREATE TABLE jamesTemplateDatabaseElement (
id TEXT NOT NULL PRIMARY KEY,
value TEXT NOT NULL,
FOREIGN KEY (id) REFERENCES jamesTemplateDatabaseMetaData(id) ON DELETE CASCADE
);
This was added later in my application, therefore I also have this migration:
CREATE TABLE jamesTemplateDatabaseElement (
id TEXT NOT NULL PRIMARY KEY,
value TEXT NOT NULL,
FOREIGN KEY (id) REFERENCES jamesTemplateDatabaseMetaData(id) ON DELETE CASCADE
);
All of which was done before: https://github.com/cashapp/sqldelight/issues/2732
In the table schema itself it's also value:
When I open that file though, the plugin hints me this:
and when alt+entering this is the generated code:
CREATE TABLE tmp_jamesTemplateDatabaseElement (id TEXT NOT NULL PRIMARY KEY, value TEXT NOT NULL);
INSERT INTO tmp_jamesTemplateDatabaseElement (id, value) SELECT id, value_ FROM jamesTemplateDatabaseElement;
DROP TABLE jamesTemplateDatabaseElement;
ALTER TABLE tmp_jamesTemplateDatabaseElement RENAME TO jamesTemplateDatabaseElement;
This kind of migration would never work though as there's no value_ column on jamesTemplateDatabaseElement. Somewhere the name from KotlinPoet is taken instead of the schema name.
Stacktrace
No response
I expect it will be this code and the implementation of asParameter using the internal utilities which allocate names via kotlinpoet instead of the raw sql
or this https://github.com/cashapp/sqldelight/blob/65449b46a89d261a4c9cd4f31b6cbfe013b4e144/sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/inspections/SchemaNeedsMigrationInspection.kt#L72