Skip to content

Commit

Permalink
probate: work around SQLite limitation
Browse files Browse the repository at this point in the history
Apparently not every version of SQLite supports LIMIT on the
DELETE statement. Now that the containers use Wolfi and not
Ubuntu, delstrike is failing to go through.

Work around this by selecting the unique ROWID from a separate
query.
  • Loading branch information
jerbmega committed Nov 24, 2024
1 parent 8fea90d commit 9eca40c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions plugins/probate.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ async def strike(ctx: lightbulb.Context) -> None:
):
try:
response = (
plugin.d["config"][ctx.guild_id][strikes_ban_message]
plugin.d["config"][ctx.guild_id]["strikes_ban_message"]
.replace("%num_strikes%", str(strike_num))
)

Expand All @@ -502,7 +502,7 @@ async def strike(ctx: lightbulb.Context) -> None:
):
try:
response = (
plugin.d["config"][ctx.guild_id][strikes_kick_message]
plugin.d["config"][ctx.guild_id]["strikes_kick_message"]
.replace("%num_strikes%", str(strike_num))
)

Expand Down Expand Up @@ -565,13 +565,13 @@ async def liststrikes(ctx: lightbulb.Context) -> None:
async def delstrike(ctx: lightbulb.Context) -> None:
strike_time = await db.query(
"probate",
f'select timestamp from strikes_{ctx.guild_id} where id == {ctx.options.user.id} and reason == "{ctx.options.reason}" limit 1',
f'select timestamp from strikes_{ctx.guild_id} where id = {ctx.options.user.id} and reason = "{ctx.options.reason}" limit 1',
)

await db.remove(
"probate",
f"strikes_{ctx.guild_id}",
f'id == {ctx.options.user.id} and reason == "{ctx.options.reason}" limit 1',
f'rowid in (select rowid from strikes_{ctx.guild_id} where id = {ctx.options.user.id} and reason = "{ctx.options.reason}" limit 1)',
)
if strike_time:
scheduler.remove_job(
Expand Down

0 comments on commit 9eca40c

Please sign in to comment.