sqldelight
sqldelight copied to clipboard
ADD COLUMN with UPDATE SET on new column fails in migration script
SQLDelight Version
2.0.1
SQLDelight Dialect
app.cash.sqldelight:sqlite-3-38-dialect:2.0.1
Describe the Bug
I added a column to my table eg. newColumn
in my migration sqm file I have:
ALTER TABLE MyTable ADD COLUMN newColumn TEXT;
That works fine. Now I really want to add some default data in the newColumn in the migration sqm file:
UPDATE MyTable SET newColumn = 'MyText';
This fails the build with. java.lang.IllegalStateException: Unexpected column alias parent SqliteAlterTableRenameColumnImpl(ALTER_TABLE_RENAME_COLUMN). It then lists the Table and all its fields, but it does not include the 'newColumn'
Am I missing something here, or is this a bug?
I saw some commits in 2.1-SNAPSHOT related to alter table but it does not seem to fix what I'm trying here.
Stacktrace
No response
🏗️ Can you add your gradle build config for sqldelight?
Seems close to the other issue where renaming not adding a column fails https://github.com/cashapp/sqldelight/issues/4897
I tried it and don't get an error currently - so there could be something extra causing it to fail 🔕
For example - I have 1.sqm
CREATE TABLE MyTable (
id TEXT NOT NULL PRIMARY KEY
);
2.sqm
ALTER TABLE MyTable ADD COLUMN newColumn TEXT;
UPDATE MyTable SET newColumn = 'MyText';