Module: CouchbaseOrm::N1ql

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
lib/couchbase-orm/n1ql.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

NO_VALUE =
:no_value_specified
DEFAULT_SCAN_CONSISTENCY =
:request_plus

Class Method Summary collapse

Class Method Details

.config(new_config = nil) ⇒ Object



23
24
25
26
27
28
# File 'lib/couchbase-orm/n1ql.rb', line 23

def self.config(new_config = nil)
    Thread.current['__couchbaseorm_n1ql_config__'] = new_config if new_config
    Thread.current['__couchbaseorm_n1ql_config__'] || {
        scan_consistency: DEFAULT_SCAN_CONSISTENCY
    }
end

.sanitize(value) ⇒ Object

sanitize for injection query



13
14
15
16
17
18
19
20
21
# File 'lib/couchbase-orm/n1ql.rb', line 13

def self.sanitize(value)
    if value.is_a?(String)
        value.gsub("'", "''").gsub("\\"){"\\\\"}.gsub('"', '\"')
    elsif value.is_a?(Array)
        value.map{ |v| sanitize(v) }
    else
        value
    end
end