https://kotlinlang.org logo
#squarelibraries
Title
# squarelibraries
h

Hristijan

03/11/2024, 10:44 AM
hey guys, is this a bug or? 🧵
I have this SQL query
Copy code
deleteWithIds:
DELETE FROM `favorite_movies` WHERE id IN ?;
and this is the generated code from SQLDelight
Copy code
public fun deleteWithIds(id: Collection<Long>) {
  val idIndexes = createArguments(count = id.size)
  driver.execute(null, """DELETE FROM `favorite_movies` WHERE id IN $idIndexes""", id.size) {
        id.forEachIndexed { index, id_ ->
          bindLong(index, id_)
        }
      }
  notifyQueries(1_142_096_770) { emit ->
    emit("favorite_movies")
  }
}
is this a bug or i am doing something wrong with creating the indexes? why it is deleting in idIndexes, i was wondering why my delete function doesn’t work 🤔 This is the table
Copy code
---TABLE
CREATE TABLE IF NOT EXISTS `favorite_movies`(
    `id` INTEGER PRIMARY KEY NOT NULL,
    `rating` REAL,
    `title` TEXT NOT NULL,
    `year` INTEGER,
    `large_cover_image` TEXT,
    `medium_cover_image` TEXT,
    `insertedAt` INTEGER NOT NULL
);
---INDICES
CREATE UNIQUE INDEX IF NOT EXISTS favorite_movies_id_idx ON `favorite_movies` (`id`,`title`);
CREATE UNIQUE INDEX IF NOT EXISTS favorite_movies_id_insertion_idx ON `favorite_movies` (`insertedAt`);
Nvm, invalidate caches and restart fixed it 😓