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
DEFAULT_ADHOC =
true

Class Method Summary collapse

Class Method Details

.config(new_config = nil) ⇒ Object



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

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

.sanitize(value) ⇒ Object

sanitize for injection query



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

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