Produces a portion of the search query from the current SQ and its children.
(self, query_fragment_callback)
| 402 | return "%s%s%s=%s" % (field, FILTER_SEPARATOR, filter_type, force_str(value)) |
| 403 | |
| 404 | def as_query_string(self, query_fragment_callback): |
| 405 | """ |
| 406 | Produces a portion of the search query from the current SQ and its |
| 407 | children. |
| 408 | """ |
| 409 | result = [] |
| 410 | |
| 411 | for child in self.children: |
| 412 | if hasattr(child, "as_query_string"): |
| 413 | result.append(child.as_query_string(query_fragment_callback)) |
| 414 | else: |
| 415 | expression, value = child |
| 416 | field, filter_type = self.split_expression(expression) |
| 417 | result.append(query_fragment_callback(field, filter_type, value)) |
| 418 | |
| 419 | conn = " %s " % self.connector |
| 420 | query_string = conn.join(result) |
| 421 | |
| 422 | if query_string: |
| 423 | if self.negated: |
| 424 | query_string = "NOT (%s)" % query_string |
| 425 | elif len(self.children) != 1: |
| 426 | query_string = "(%s)" % query_string |
| 427 | |
| 428 | return query_string |
| 429 | |
| 430 | def split_expression(self, expression): |
| 431 | """Parses an expression and determines the field and filter type.""" |
no test coverage detected