(self, op, value)
| 150 | return None |
| 151 | |
| 152 | def prepare_query_value(self, op, value): |
| 153 | if not isinstance(op, str): |
| 154 | return value |
| 155 | |
| 156 | if op in STRING_OPERATORS: |
| 157 | case_insensitive = op.startswith("i") |
| 158 | op = op.lstrip("i") |
| 159 | |
| 160 | flags = re.IGNORECASE if case_insensitive else 0 |
| 161 | |
| 162 | regex = r"%s" |
| 163 | if op == "startswith": |
| 164 | regex = r"^%s" |
| 165 | elif op == "endswith": |
| 166 | regex = r"%s$" |
| 167 | elif op == "exact": |
| 168 | regex = r"^%s$" |
| 169 | elif op == "wholeword": |
| 170 | regex = r"\b%s\b" |
| 171 | elif op == "regex": |
| 172 | regex = value |
| 173 | |
| 174 | if op == "regex": |
| 175 | value = re.compile(regex, flags) |
| 176 | else: |
| 177 | # escape unsafe characters which could lead to a re.error |
| 178 | value = re.escape(value) |
| 179 | value = re.compile(regex % value, flags) |
| 180 | return super().prepare_query_value(op, value) |
| 181 | |
| 182 | |
| 183 | class URLField(StringField): |
nothing calls this directly
no test coverage detected