@@ -85,6 +85,7 @@ def field_names(self) -> set[str]:
85
85
"""Return a set with field names that this query operates on."""
86
86
return set ()
87
87
88
+ @abstractmethod
88
89
def clause (self ) -> tuple [str | None , Sequence [Any ]]:
89
90
"""Generate an SQLite expression implementing the query.
90
91
@@ -95,14 +96,12 @@ def clause(self) -> tuple[str | None, Sequence[Any]]:
95
96
The default implementation returns None, falling back to a slow query
96
97
using `match()`.
97
98
"""
98
- return None , ()
99
99
100
100
@abstractmethod
101
101
def match (self , obj : Model ):
102
102
"""Check whether this query matches a given Model. Can be used to
103
103
perform queries on arbitrary sets of Model.
104
104
"""
105
- ...
106
105
107
106
def __and__ (self , other : Query ) -> AndQuery :
108
107
return AndQuery ([self , other ])
@@ -152,7 +151,7 @@ def __init__(self, field_name: str, pattern: P, fast: bool = True):
152
151
self .fast = fast
153
152
154
153
def col_clause (self ) -> tuple [str , Sequence [SQLiteType ]]:
155
- return self . field , ()
154
+ raise NotImplementedError
156
155
157
156
def clause (self ) -> tuple [str | None , Sequence [SQLiteType ]]:
158
157
if self .fast :
@@ -164,7 +163,7 @@ def clause(self) -> tuple[str | None, Sequence[SQLiteType]]:
164
163
@classmethod
165
164
def value_match (cls , pattern : P , value : Any ):
166
165
"""Determine whether the value matches the pattern."""
167
- raise NotImplementedError ()
166
+ raise NotImplementedError
168
167
169
168
def match (self , obj : Model ) -> bool :
170
169
return self .value_match (self .pattern , obj .get (self .field_name ))
@@ -234,7 +233,7 @@ def string_match(
234
233
"""Determine whether the value matches the pattern. Both
235
234
arguments are strings. Subclasses implement this method.
236
235
"""
237
- raise NotImplementedError ()
236
+ raise NotImplementedError
238
237
239
238
240
239
class StringQuery (StringFieldQuery [str ]):
0 commit comments