コード例 #1
0
ファイル: FullTextKey.py プロジェクト: poses/erp5
 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
コード例 #2
0
 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)
コード例 #3
0
ファイル: DefaultKey.py プロジェクト: MarkTang/erp5
 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
コード例 #4
0
 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
コード例 #5
0
ファイル: KeywordKey.py プロジェクト: Verde1705/erp5
 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)
コード例 #6
0
ファイル: DefaultKey.py プロジェクト: MarkTang/erp5
 def _guessComparisonOperator(self, value):
   if isinstance(value, basestring) and '%' in value:
     operator = 'like'
   else:
     operator = SearchKey._guessComparisonOperator(self, value)
   return operator
コード例 #7
0
 def _guessComparisonOperator(self, value):
     if isinstance(value, basestring) and '%' in value:
         operator = 'like'
     else:
         operator = SearchKey._guessComparisonOperator(self, value)
     return operator