From d498673020e7144ed59865ab1746d97307c1c529 Mon Sep 17 00:00:00 2001 From: Conatum Date: Wed, 22 Dec 2021 10:34:34 +0200 Subject: [PATCH] sharding (data): Add `SHARDID` condition. --- bot/data/conditions.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/bot/data/conditions.py b/bot/data/conditions.py index 4687a929..fdd0739f 100644 --- a/bot/data/conditions.py +++ b/bot/data/conditions.py @@ -70,5 +70,17 @@ class Constant(Condition): conditions.append("{} {}".format(key, self.value)) +class SHARDID(Condition): + __slots__ = ('shardid', 'shard_count') + + def __init__(self, shardid, shard_count): + self.shardid = shardid + self.shard_count = shard_count + + def apply(self, key, values, conditions): + conditions.append("({} >> 22) %% {} = {}".format(key, self.shard_count, _replace_char)) + values.append(self.shardid) + + NULL = Constant('IS NULL') NOTNULL = Constant('IS NOT NULL')