From b20d37e2529e79fe1e84ac5e5594c49ede7f67a4 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Mon, 10 Nov 2025 11:40:20 +0100 Subject: [PATCH] Refactor `PersonalKitTable` to use explicit ID column initialization and update `create` method to utilize `insert` operation. Signed-off-by: Chaoscaot --- .../SQL/src/de/steamwar/sql/PersonalKit.kt | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/CommonCore/SQL/src/de/steamwar/sql/PersonalKit.kt b/CommonCore/SQL/src/de/steamwar/sql/PersonalKit.kt index 76702804..5e369415 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/PersonalKit.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/PersonalKit.kt @@ -27,14 +27,19 @@ import org.jetbrains.exposed.v1.core.dao.id.EntityID import org.jetbrains.exposed.v1.core.eq import org.jetbrains.exposed.v1.dao.CompositeEntity import org.jetbrains.exposed.v1.dao.CompositeEntityClass +import org.jetbrains.exposed.v1.jdbc.insert object PersonalKitTable: CompositeIdTable("PersonalKit") { val userId = reference("UserId", SteamwarUserTable) - val gamemode = varchar("Gamemode", 64) - val kitName = varchar("Name", 64) + val gamemode = varchar("Gamemode", 64).entityId() + val kitName = varchar("Name", 64).entityId() val inventory = text("Inventory") val armor = text("Armor") val inUse = bool("InUse") + + init { + addIdColumn(userId) + } } class InternalKit(id: EntityID): CompositeEntity(id) { @@ -53,14 +58,15 @@ class InternalKit(id: EntityID): CompositeEntity(id) { @JvmStatic fun create(userId: Int, gamemode: String, kitName: String, rawInventory: String, rawArmor: String) = useDb { - new { - this.userID = userId - this.gamemode = gamemode - this.name = kitName - this.inUse = true - this.rawInventory = rawInventory - this.rawArmor = rawArmor + PersonalKitTable.insert { + it[this.userId] = EntityID(userId, SteamwarUserTable) + it[this.gamemode] = gamemode + it[this.kitName] = kitName + it[this.inventory] = rawInventory + it[this.armor] = rawArmor + it[this.inUse] = true } + get(userId, gamemode, kitName) } @JvmStatic