MCPcopy Create free account
hub / github.com/couchbase/couchbase-python-client / create_query_object

Method create_query_object

couchbase/logic/n1ql.py:691–729  ·  view source on GitHub ↗
(cls, statement, *options, **kwargs)

Source from the content-addressed store, hash-verified

689
690 @classmethod
691 def create_query_object(cls, statement, *options, **kwargs):
692 # lets make a copy of the options, and update with kwargs...
693 opt = QueryOptions()
694 # TODO: is it possible that we could have [QueryOptions, QueryOptions, ...]??
695 # If so, why???
696 opts = list(options)
697 for o in opts:
698 if isinstance(o, (QueryOptions, QueryOptionsBase)):
699 opt = o
700 opts.remove(o)
701 args = opt.copy()
702 args.update(kwargs)
703
704 # now lets get positional parameters. Actual positional
705 # params OVERRIDE positional_parameters
706 positional_parameters = args.pop("positional_parameters", [])
707 if opts and len(opts) > 0:
708 positional_parameters = opts
709
710 # now the named parameters. NOTE: all the kwargs that are
711 # not VALID_OPTS must be named parameters, and the kwargs
712 # OVERRIDE the list of named_parameters
713 new_keys = list(filter(lambda x: x not in cls._VALID_OPTS, args.keys()))
714 named_parameters = args.pop("named_parameters", {})
715 for k in new_keys:
716 named_parameters[k] = args[k]
717
718 query = cls(statement, *positional_parameters, **named_parameters)
719 # now lets try to setup the options.
720 # but for now we will use the existing N1QLQuery. Could be we can
721 # add to it, etc...
722
723 # default to false on metrics
724 query.metrics = args.get("metrics", False)
725
726 for k, v in ((k, args[k]) for k in (args.keys() & cls._VALID_OPTS)):
727 for target, transform in cls._VALID_OPTS[k].items():
728 setattr(query, target, transform(v))
729 return query
730
731
732class QueryRequestLogic:

Calls 7

QueryOptionsClass · 0.90
updateMethod · 0.80
removeMethod · 0.45
popMethod · 0.45
keysMethod · 0.45
getMethod · 0.45
itemsMethod · 0.45

Tested by 15

test_params_baseMethod · 0.36
test_params_priorityMethod · 0.36
test_params_read_onlyMethod · 0.36
test_params_timeoutMethod · 0.36
test_consistent_withMethod · 0.36
test_params_adhocMethod · 0.36
test_params_baseMethod · 0.36