Class: Couchbase::Protostellar::RequestGenerator::Query Private

Inherits:
Object
  • Object
show all
Defined in:
lib/couchbase/protostellar/request_generator/query.rb

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

Constant Summary collapse

SCAN_CONSISTENCY_MAP =

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

{
  :not_bounded => :SCAN_CONSISTENCY_NOT_BOUNDED,
  :request_plus => :SCAN_CONSISTENCY_REQUEST_PLUS,
}.freeze
PROFILE_MODE_MAP =

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

{
  :off => :PROFILE_MODE_OFF,
  :phases => :PROFILE_MODE_PHASES,
  :timings => :PROFILE_MODE_TIMINGS,
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bucket_name: nil, scope_name: nil) ⇒ Query

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.

Returns a new instance of Query.



41
42
43
44
# File 'lib/couchbase/protostellar/request_generator/query.rb', line 41

def initialize(bucket_name: nil, scope_name: nil)
  @bucket_name = bucket_name
  @scope_name = scope_name
end

Instance Attribute Details

#bucket_nameObject (readonly)

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.



38
39
40
# File 'lib/couchbase/protostellar/request_generator/query.rb', line 38

def bucket_name
  @bucket_name
end

#scope_nameObject (readonly)

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.



39
40
41
# File 'lib/couchbase/protostellar/request_generator/query.rb', line 39

def scope_name
  @scope_name
end

Instance Method Details

#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.



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 && true)
end