Class: Blazer::Adapters::Neo4jAdapter
Instance Attribute Summary
Attributes inherited from BaseAdapter
#data_source
Instance Method Summary
collapse
Methods inherited from BaseAdapter
#cachable?, #cancel, #cohort_analysis_statement, #cost, #explain, #initialize, #reconnect, #schema, #supports_cohort_analysis?
Instance Method Details
#parameter_binding ⇒ Object
42
43
44
45
46
47
48
49
|
# File 'lib/blazer/adapters/neo4j_adapter.rb', line 42
def parameter_binding
proc do |statement, variables|
variables.each_key do |k|
statement = statement.gsub("{#{k}}") { "$#{k} " }
end
[statement, variables]
end
end
|
#preview_statement ⇒ Object
33
34
35
|
# File 'lib/blazer/adapters/neo4j_adapter.rb', line 33
def preview_statement
"MATCH (n:{table}) RETURN n LIMIT 10"
end
|
#quoting ⇒ Object
38
39
40
|
# File 'lib/blazer/adapters/neo4j_adapter.rb', line 38
def quoting
:backslash_escape
end
|
#run_statement(statement, comment, bind_params) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/blazer/adapters/neo4j_adapter.rb', line 4
def run_statement(statement, , bind_params)
columns = []
rows = []
error = nil
begin
result = session.query("#{statement} /*#{}*/", bind_params)
columns = result.columns.map(&:to_s)
rows = []
result.each do |row|
rows << columns.map do |c|
v = row.send(c)
v = v.properties if v.respond_to?(:properties)
v
end
end
rescue => e
error = e.message
error = Blazer::VARIABLE_MESSAGE if error.include?("Invalid input '$'")
end
[columns, rows, error]
end
|
#tables ⇒ Object
28
29
30
31
|
# File 'lib/blazer/adapters/neo4j_adapter.rb', line 28
def tables
result = session.query("CALL db.labels()")
result.rows.map(&:first)
end
|