fix(db): correct user.update target table
stmt.user.update was issuing UPDATE guilds instead of UPDATE users, so any DB.user.update() call would silently corrupt guild rows that happened to share the same WHERE clause shape and never touch the intended user row.
This commit is contained in:
@@ -55,7 +55,7 @@ const stmt = {
|
|||||||
update: (data: UserType) => {
|
update: (data: UserType) => {
|
||||||
const keys = Object.keys(data).filter(k => k !== "guild_id" && k !== "id");
|
const keys = Object.keys(data).filter(k => k !== "guild_id" && k !== "id");
|
||||||
if (keys.length === 0) throw new Error("update: 키1개는 있어야함");
|
if (keys.length === 0) throw new Error("update: 키1개는 있어야함");
|
||||||
return database.prepare(`UPDATE guilds SET ${
|
return database.prepare(`UPDATE users SET ${
|
||||||
keys.map(k => `${k} = @${k}`).join(", ")
|
keys.map(k => `${k} = @${k}`).join(", ")
|
||||||
} WHERE guild_id = @guild_id AND id = @id`).run(data);
|
} WHERE guild_id = @guild_id AND id = @id`).run(data);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user