Extract the actual query (not pattern) from operations.
497891
def actual_query(self):
        """"""
        if not self._actual_query:

            # trigger evaluation of operation
            if (self.operation in ['query', 'getmore', 'update', 'remove'] or
                    self.command in ['count', 'findandmodify']):
                self._actual_query = self._find_pattern('query: ', actual=True)
            elif self.command == 'find':
                self._actual_query = self._find_pattern('filter: ',
                                                        actual=True)

        return self._actual_query
1123319
def query(self, query=None):
        
        if query is None:
            return self.url.query
        self.url.query = query
843228
def _process_query(self, query):
        """"""
        key, val = query
        field_name, field_action = split_field_action(key)

        # Boost by name__action overrides boost by name.
        boost = self.field_boosts.get(key)
        if boost is None:
            boost = self.field_boosts.get(field_name)

        handler_name = 'process_query_{0}'.format(field_action)

        if field_action and hasattr(self, handler_name):
            return getattr(self, handler_name)(field_name, val, field_action)

        elif field_action in QUERY_ACTION_MAP:
            return {
                QUERY_ACTION_MAP[field_action]: _boosted_value(
                    field_name, field_action, key, val, boost)
            }

        elif field_action == 'query_string':
            # query_string has different syntax, so it's handled
            # differently.
            #
            # Note: query_string queries are not boosted with
            # .boost()---they're boosted in the query text itself.
            return {
                'query_string': {'default_field': field_name, 'query': val}
            }

        elif field_action in RANGE_ACTIONS:
            # Ranges are special and have a different syntax, so
            # we handle them separately.
            return {
                'range': {field_name: _boosted_value(
                        field_action, field_action, key, val, boost)}
           }

        elif field_action == 'range':
            lower, upper = val
            value = {
                'gte': lower,
                'lte': upper,
            }
            if boost:
                value['boost'] = boost

            return {'range': {field_name: value}}

        raise InvalidFieldActionError(
            '%s is not a valid field action' % field_action)
89363
def extract_queries(self, args, kwargs):
        '''
            
        '''
        return super(MySQLExtPillar, self).extract_queries(args, kwargs)
1185775
def AQLQuery(self, query, batchSize = 100, rawResults = False, bindVars = {}, options = {}, count = False, fullCount = False,
                 json_encoder = None, **moreArgs) :
        """"""
        return AQLQuery(self, query, rawResults = rawResults, batchSize = batchSize, bindVars  = bindVars, options = options, count = count, fullCount = fullCount,
                        json_encoder = json_encoder, **moreArgs)
1291068
def query(self):
        """"""
        if self._query is None:
            query_string = self.environ.get('QUERY_STRING')
            self._query = QueryDict([
                (k.decode('utf-8'), v.decode('utf-8'))
                for k, v in urlparse.parse_qsl(
                    query_string, keep_blank_values=True)
            ])
        return self._query
192898
def raw(self, query):
        
        clone = copy.deepcopy(self)
        clone.adapter._pre_compiled_query = query
        clone.adapter.compiled_query = query
        return clone
38002
def extract_values(query):
    
    # pylint
    if isinstance(query, subqueries.UpdateQuery):
        row = query.values
        return extract_values_inner(row, query)
    if isinstance(query, subqueries.InsertQuery):
        ret = []
        for row in query.objs:
            ret.append(extract_values_inner(row, query))
        return ret
    raise NotSupportedError
1357512
def _get_repo_filter(self, query):
        
        if self.filter is not None:
            return query.extra(where=[self.filter])
        return query
713103
def convert_query_to_sql_statement(query):
    
    context = query._compile_context()
    context.statement.use_labels = False
    return context.statement
944704
def sql(self, query):
        
        # Get the schema by adding a LIMIT 0 on to the end of the query. If
        # there is already a limit in the query, we find and remove it
        limited_query = 'SELECT * FROM ({}) t0 LIMIT 0'.format(query)
        schema = self._get_schema_using_query(limited_query)
        return ops.SQLQueryResult(query, schema, self).to_expr()
1202982
def clean_query(self):
        
        if self.query:
            for key, value in self.query.items():
                if isinstance(value, list) and None in value:
                    self.query[key] = [v for v in value if v is not None]
1235581
def get_rewritten_query(self):
        
        rewrittenQuery = self._extract(_PartitionedQueryExecutionInfo.RewrittenQueryPath)
        if rewrittenQuery is not None:
            # Hardcode formattable filter to true for now 
            rewrittenQuery = rewrittenQuery.replace('{documentdb-formattableorderbyquery-filter}', 'true')
        return rewrittenQuery
870682
def query(self, query, *parameters, **kwargs):
        """"""
        cursor = self._cursor()
        try:
            self._execute(cursor, query, parameters or None, kwargs)
            if cursor.description:
                column_names = [column.name for column in cursor.description]
                res = [Row(zip(column_names, row)) for row in cursor.fetchall()]
                cursor.close()
                return res
        except:
            cursor.close()
            raise
1154146
def __query_spec(self):
        """"""
        spec = self.__spec
        if not self.__is_command and "$query" not in self.__spec:
            spec = SON({"$query": self.__spec})
        if self.__ordering:
            spec["$orderby"] = self.__ordering
        if self.__explain:
            spec["$explain"] = True
        if self.__hint:
            spec["$hint"] = self.__hint
        if self.__comment:
            spec["$comment"] = self.__comment
        if self.__snapshot:
            spec["$snapshot"] = True
        if self.__max_scan:
            spec["$maxScan"] = self.__max_scan
        return spec
350181
def _get_query_params(query):
    
    query_params = OrderedDict(sorted(query['query'].items()))
    return ' '.join(['{}={}'.format(k, v) for k, v in query_params.items()])
789632
def split_query(query: str) -> List[str]:
    
    try:
        _query = query.strip()
    except (ValueError, AttributeError):
        raise QueryParserException('query is not valid, received instead {}'.format(query))

    expressions = _query.split(',')
    expressions = [exp.strip() for exp in expressions if exp.strip()]
    if not expressions:
        raise QueryParserException('Query is not valid: {}'.format(query))

    return expressions