def _processSearchValue(self, search_value, logical_operator, comparison_operator): """ Special SearchValue processor for FullText queries: if a searched value from 'match' operator group contains an operator recognised in boolean mode, make the operator for that value be 'match_boolean'. """ operator_value_dict, logical_operator, parsed = \ SearchKey._processSearchValue(self, search_value, logical_operator, comparison_operator) new_value_list = [] append = new_value_list.append for value in operator_value_dict.pop('match', []): if isinstance(value, basestring) and \ FULLTEXT_BOOLEAN_DETECTOR.match(value) is not None: operator_value_dict.setdefault('match_boolean', []).append(value) else: append(value) if len(new_value_list): if 'match_boolean' in operator_value_dict: # use boolean mode for all expressions operator_value_dict['match_boolean'].extend(new_value_list) else: operator_value_dict['match'] = new_value_list return operator_value_dict, logical_operator, parsed
def _buildQuery(self, operator_value_dict, logical_operator, parsed, group): """ Treat "!=" operator specialy: - if the value contains at least one "%", change operator into "not like" - otherwise, let it go untouched """ result = [] if '!=' in operator_value_dict: column = self.getColumn() original_different_list = operator_value_dict.pop('!=') different_list = [] for value in original_different_list: if isinstance(value, basestring) and '%' in value: result.append( SimpleQuery(search_key=self, group=group, comparison_operator='not like', **{column: value})) else: different_list.append(value) if len(different_list): operator_value_dict['!='] = different_list return result + SearchKey._buildQuery(self, operator_value_dict, logical_operator, parsed, group)
def buildSearchTextExpression(self, operator, value, column=None): operator_text = operator.getOperator() if column is None: column = self.getColumn() if operator_text == 'like': assert isinstance(value, basestring) assert '%' in value result = self._renderValueAsSearchText(value, operator) if len(column): result = '%s:%s' % (column, result) else: result = SearchKey.buildSearchTextExpression(self, operator, value, column=column) return result
def _buildQuery(self, operator_value_dict, logical_operator, parsed, group): """ Treat "!=" operator specialy: - if the value contains at least one "%", change operator into "not like" - otherwise, let it go untouched """ result = [] if '!=' in operator_value_dict: column = self.getColumn() original_different_list = operator_value_dict.pop('!=') different_list = [] for value in original_different_list: if isinstance(value, basestring) and '%' in value: result.append(SimpleQuery(search_key=self, group=group, comparison_operator='not like', **{column: value})) else: different_list.append(value) if len(different_list): operator_value_dict['!='] = different_list return result + SearchKey._buildQuery(self, operator_value_dict, logical_operator, parsed, group)
def _guessComparisonOperator(self, value): if isinstance(value, basestring) and '%' in value: operator = 'like' else: operator = SearchKey._guessComparisonOperator(self, value) return operator