我想删除给定列表as_counter,t_ms
和值的表中的行as_counter
,t_ms
并存在于列表中。
数据库
CREATE TABLE Event(
as_counter TEXT NOT NULL,
t_ms TEXT NOT NULL,
event_map TEXT NOT NULL,
PRIMARY KEY (as_counter, t_ms)
);
insertEvent:
INSERT OR REPLACE INTO Event (as_counter, t_ms, event_map)
VALUES (?, ?, ?);
deleteEventListByKey:
DELETE FROM Event
WHERE (as_counter,t_ms) IN (VALUES(?,?))
我尝试过的方法是在 deleteEventListByKey 中。但是我收到了错误'(', ')', '.', <binary like operator real>, BETWEEN or IN expected, got ','
。我不确定为什么会收到此错误。
我试图通过的测试用例
@Test
fun `delete events by list of primary keys`() {
queries.insertEvent("1", "1", "{Click,Open}")
queries.insertEvent("1", "2", "{Click,Close},{Read,Open}")
queries.insertEvent("1", "3", "{Click,Open}")
queries.insertEvent("2", "3", "{Click,Open}")
queries.deleteEventsByKey([("1,2"),("1,1")])
assertThat(queries.selectAllEvents().executeAsList())
.containsExactly(
Event(
as_counter = "1",
t_ms = "1",
event_map = "{Click,Open}"
),
Event(
as_counter = "1",
t_ms = "2",
event_map = "{Click,Close},{Read,Open}"
)
)
}
有谁知道如何为 SQLdelight(SQLLite) 编写查询,在给定列表输入的情况下,如果数据库中存在并且表中的条目将被as_counter
删除t_ms
?