mirror of
https://github.com/beetbox/beets.git
synced 2025-12-25 01:53:31 +01:00
dbcore: Actually normalize RegexpQuery pattern
unintentionally, the pattern normalization added in
1c3a053ce5 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
This commit is contained in:
parent
b19b961035
commit
7fbf562d24
1 changed files with 3 additions and 2 deletions
|
|
@ -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]
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue