I've got a simple table delcaration in sqldelight....
# squarelibraries
c
I've got a simple table delcaration in sqldelight. Run the app. Installs fine. I go to update the table (add a new column) run the app and seems to run fine. I was expecting a crash since I didn't write a migration. Any ideas? (when I'm running the app I write into the table, so at the very least i thought a crash would happen here)
j
Is AS uninstalling before installing?
c
nope. my other data like shared prefs/datastore is still there.
maybe after changing the table i have to run the sqldelight gradle tasks. let me try that (again)
im reaching here. but maybe column additions dont break things. let me try to remove columns. lol
seems like i dind't have to rerun any of those gradle tasks since they ran after i ran my app because i got compile issues of missing params.
no dice.
Task 'generateMainRollerDbSchema' not found in project ':persistence-layer'. hmmrmrmrmm
interesting. looks like switching branches is the culprit of the above error. that generate task should not be there
nope. no idea why its not crashing. i guess ill try some minimal repro tomorrow and file a bug.
e
It's possible that it won't crash until you try to use it
c
I am using it (deleting items and inserting more)
e
How are you inserting? Is the new column explicitly mentioned?
p
Did you check the generated code?
c
Nope! That's a good idea!
I guess I could also actually pull the db and check the table that way too. ill do that today
So I finally got to circling back to this today. How the heck isn't this crashing? Ran a build. Did a query on my table. no crash (as expected). then i added a new property/column to the table. the ide sqldelight plugin reminds me i need to do a migration. i dont do one. i run the app and run a query against my table. no crash (unexpected... shouldn't it crash)? attached is the tooltip from the sqldelight plugin that i need to do a migration. I checked the genreated code. the new generated model includes the new property i added and the generated queries has the updated query .
e
Does the query reference the newly added column?
So if you have
Copy code
CREATE TABLE Foo(
  id TEXT NOT NULL
);

find:
SELECT id FROM Foo;
And then you update the table
Copy code
CREATE TABLE Foo(
  id TEXT NOT NULL,
  bar TEXT
);
I don't think that running
find
would crash.
c
Yeah. I just updated it to run an insert. and the insert is what caused the crash. not the query. phew. glad something caused a crash at least. i was going crazy. lol