This might not be the right place to ask this, (if...
# kotlin-native
a
This might not be the right place to ask this, (if so let me know)… I’m wondering if anyone else has experienced an issue with SQLDelight on native incrementing primary keys when doing a
INSERT OR REPLACE INTO (id, ...) VALUES(?, ...)
operation? So if I had a null id passed in for the primary key… it makes sense, but I’m not passing in a null. Any advice would be helpful.
this is how my table looks:
Copy code
CREATE TABLE `User`(
 `id` INTEGER PRIMARY KEY AUTOINCREMENT, ...)
Copy code
insert:
INSERT OR REPLACE INTO User (id, ...) VALUES (?, ...)
when I run that query it seems that my primary key always ends up getting incremented after the initial insert.
I also have a unique index on the table… I wonder if maybe that plays a roll?
weirdly… as far as I’m aware this is only an issue on iOS and not on Android.
k
I feel like insert or replace should work and isn’t necessarily related to that bug (I wrote the driver, for context).
a
I was using NativeSqliteDriver(db.Schema, “some.db”, maxReaderConnections = 4)… and I think it was causing issues since it might have a race condition or something. Thoughts?
I changed it back to maxReaderConnections = 1
and things seem to work properly
k
Huh. I’ll have to look at it. The reader queue was added after the driver had been around for a while and may have caused an issue we hadn’t run into previously, although this seems pretty odd and not something I would’ve expected (but, that’s kind of how all bugs work, so…)
a
totally. 😂 I’ll dig at it some more too. could possible be some sort of race condition or something in my code as well.