Method: Couchbase::Protostellar::RequestGenerator::Query#query_request

Defined in:
lib/couchbase/protostellar/request_generator/query.rb

#query_request(statement, options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/couchbase/protostellar/request_generator/query.rb', line 46

def query_request(statement, options)
  proto_opts = {}

  bucket_name = @bucket_name
  scope_name = @scope_name
  unless options.scope_qualifier.nil?
    if options.scope_qualifier.include? ":"
      bucket_name, scope_name = options.scope_qualifier.split(":")[1].split(".")
    else
      bucket_name, scope_name = options.scope_qualifier.split(".")
    end
  end
  proto_opts[:scope_name] = scope_name unless scope_name.nil?
  proto_opts[:bucket_name] = bucket_name unless bucket_name.nil?

  proto_opts[:read_only] = options.readonly unless options.readonly.nil?
  proto_opts[:prepared] = !options.adhoc

  tuning_opts = create_tuning_options(options)
  proto_opts[:tuning_options] = tuning_opts unless tuning_opts.nil?

  proto_opts[:client_context_id] = options.client_context_id unless options.client_context_id.nil?
  unless options.instance_variable_get(:@scan_consistency).nil?
    proto_opts[:scan_consistency] =
      SCAN_CONSISTENCY_MAP[options.instance_variable_get(:@scan_consistency)]
  end
  proto_opts[:positional_parameters] = options.export_positional_parameters unless options.export_positional_parameters.nil?
  proto_opts[:named_parameters] = options.export_named_parameters unless options.export_named_parameters.nil?
  proto_opts[:flex_index] = options.flex_index unless options.flex_index.nil?
  proto_opts[:preserve_expiry] = options.preserve_expiry unless options.preserve_expiry.nil?
  proto_opts[:consistent_with] = get_consistent_with(options) unless options.mutation_state.nil?
  proto_opts[:profile_mode] = PROFILE_MODE_MAP[options.profile]

  proto_req = Generated::Query::V1::QueryRequest.new(
    statement: statement,
    **proto_opts
  )

  create_query_request(proto_req, :query, options, idempotent: options.readonly)
end