From 7fbf562d242850ec05c2c79ff3c95d542892f191 Mon Sep 17 00:00:00 2001 From: wisp3rwind <17089248+wisp3rwind@users.noreply.github.com> Date: Sun, 25 Jun 2023 10:06:35 +0200 Subject: [PATCH] dbcore: Actually normalize RegexpQuery pattern unintentionally, the pattern normalization added in 1c3a053ce590f014363ea2735b793c9a6fb7717b was a no-op, and only value normalization was actually applied (since self.pattern was left unchanged) This also helps with typing by ensuring that variables have fixed types --- beets/dbcore/query.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/beets/dbcore/query.py b/beets/dbcore/query.py index 295632ad7..48bc8e4e2 100644 --- a/beets/dbcore/query.py +++ b/beets/dbcore/query.py @@ -265,16 +265,17 @@ class RegexpQuery(StringFieldQuery): """ def __init__(self, field: str, pattern: str, fast: bool = True): - super().__init__(field, pattern, fast) pattern = self._normalize(pattern) try: - self.pattern = re.compile(self.pattern) + pattern_re = re.compile(pattern) except re.error as exc: # Invalid regular expression. raise InvalidQueryArgumentValueError(pattern, "a regular expression", format(exc)) + super().__init__(field, pattern_re, fast) + def col_clause(self): return f" regexp({self.field}, ?)", [self.pattern.pattern]