使用 Jetbrains Exposed 了解“insertIgnore”的结果

问题描述

我正在使用 Jetbrains Exposed 与我的 MysqL 5.7 数据库进行交互。
我的问题是 insertIgnore

在我看来,没有办法知道语句的结果。如果插入了一行,MysqL 本身将返回 1,如果由于错误(在我的情况下,重复键错误)而被忽略,则返回 0。
但是从插入的结果中我看不到任何方法

我的代码基本上就是:

transaction(database) {
  MyTable.insertIgnore {
    it[uniqueColumn] = "foo"
  }
}

执行两次,其中 uniqueColumn 是唯一的。结果没有区别,虽然第一次成功,第二次没有。

在某处表示该语句的结果行似乎很容易,但我自己或谷歌搜索时找不到任何东西。

解决方法

我遇到了类似的问题,我使用 IntIdTable 而不是 Table 解决了它 和 insertIgnoreAndGetId 而不是 insertIgnore

也许它会帮助任何人