3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

Fix antiraid level upsert for MySQL

This commit is contained in:
Dragory 2020-09-15 00:59:46 +03:00
parent 49cefe406e
commit f916e8c156
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -27,6 +27,7 @@ export class GuildAntiraidLevels extends BaseGuildRepository {
});
} else {
// Upsert: https://stackoverflow.com/a/47064558/316944
// But the MySQL version: https://github.com/typeorm/typeorm/issues/1090#issuecomment-634391487
await this.antiraidLevels
.createQueryBuilder()
.insert()
@ -34,8 +35,10 @@ export class GuildAntiraidLevels extends BaseGuildRepository {
guild_id: this.guildId,
level,
})
.onConflict('("guild_id") DO UPDATE SET "guild_id" = :guildId')
.setParameter("guildId", this.guildId)
.orUpdate({
conflict_target: ["guild_id"],
overwrite: ["level"],
})
.execute();
}
}