Reputation: 195
I'm using Jetbrains Exposed to interact with my MySQL 5.7 database.
The problem I have is with insertIgnore
.
As I see it, there is no way of knowing the result of the statement. MySQL itself will return either 1 if a row was inserted, or 0 if it was ignored because of an error (in my case, duplicate key error).
But I can't see any way to see that from the result of the insert.
My code is basically just:
transaction(database) {
MyTable.insertIgnore {
it[uniqueColumn] = "foo"
}
}
Executed twice where uniqueColumn
is unique. There is no difference in the results, although the first time is successful and the second time isn't.
It seems like an easy thing to have the resulted rows of that statement be represented somewhere, but I couldn't find anything myself or when googling.
Upvotes: 0
Views: 864
Reputation: 11
I had a similar problem and I solved it using IntIdTable instead of Table And insertIgnoreAndGetId instead of insertIgnore
Maybe it will help anyone
Upvotes: 1