support #381
@ -30,7 +30,8 @@ CREATE TRIGGER `TR_ShortRoleNamesDelete`
|
||||
ON `ShortRoleNames`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO `ShortRoleNamesHistory` (`Id`, `ShortName`, `DiscordRoleId`, `ServerId`, `Deleted`, `DateFrom`,
|
||||
INSERT INTO `ShortRoleNamesHistory` (`Id`, `ShortName`, `DiscordRoleId`, `Position`, `ServerId`, `Deleted`,
|
||||
`DateFrom`,
|
||||
`DateTo`)
|
||||
VALUES (OLD.Id, OLD.ShortName, OLD.DiscordRoleId, OLD.Position, OLD.ServerId, TRUE, OLD.LastModifiedAt,
|
||||
CURRENT_TIMESTAMP(6));
|
||||
|
@ -107,12 +107,12 @@ class ShortRoleName(TableABC):
|
||||
return str(
|
||||
f"""
|
||||
INSERT INTO `ShortRoleNames` (
|
||||
`Name`, `DiscordRoleId`, `Position`, `ServerId`
|
||||
`ShortName`, `DiscordRoleId`, `Position`, `ServerId`
|
||||
) VALUES (
|
||||
'{self._short_name}',
|
||||
{self._discord_role_id}
|
||||
{self._discord_role_id},
|
||||
'{self._position}',
|
||||
{self._server.id},
|
||||
{self._server.id}
|
||||
);
|
||||
"""
|
||||
)
|
||||
@ -122,7 +122,7 @@ class ShortRoleName(TableABC):
|
||||
return str(
|
||||
f"""
|
||||
UPDATE `ShortRoleNames`
|
||||
SET `Name` = '{self._short_name}',
|
||||
SET `ShortName` = '{self._short_name}',
|
||||
`DiscordRoleId` = {self._discord_role_id},
|
||||
`Position` = '{self._position}',
|
||||
`ServerId` = {self._server.id}
|
||||
|
@ -46,4 +46,5 @@ input ShortRoleNameInput {
|
||||
roleId: String
|
||||
roleName: String
|
||||
position: String
|
||||
serverId: ID
|
||||
}
|
@ -36,10 +36,15 @@ class ShortRoleNameMutation(QueryABC):
|
||||
|
||||
short_role_name = ShortRoleName(
|
||||
input["shortName"],
|
||||
input["roleId"],
|
||||
int(input["roleId"]),
|
||||
input["position"],
|
||||
server,
|
||||
)
|
||||
|
||||
result = self._short_role_names.find_short_role_name_by_role_id(short_role_name.role_id)
|
||||
if result is not None:
|
||||
raise ValueError("Short name for role already exists")
|
||||
|
||||
self._short_role_names.add_short_role_name(short_role_name)
|
||||
self._db.save_changes()
|
||||
|
||||
@ -47,7 +52,7 @@ class ShortRoleNameMutation(QueryABC):
|
||||
return (
|
||||
srn.short_name == short_role_name.short_name
|
||||
and srn.role_id == short_role_name.role_id
|
||||
and srn.position == short_role_name.position
|
||||
and srn.position.value == short_role_name.position
|
||||
)
|
||||
|
||||
return (
|
||||
|
Loading…
Reference in New Issue
Block a user