Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
129 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module Neo4j | ||
module Core | ||
class CypherSession | ||
module Adaptors | ||
module Schema | ||
def version(session) | ||
result = query(session, 'CALL dbms.components()', {}, skip_instrumentation: true) | ||
|
||
# BTW: community / enterprise could be retrieved via `result.first.edition` | ||
result.first.versions[0] | ||
end | ||
|
||
def indexes(session) | ||
result = query(session, 'CALL db.indexes()', {}, skip_instrumentation: true) | ||
|
||
result.map do |row| | ||
label, property = row.description.match(/INDEX ON :([^\(]+)\(([^\)]+)\)/)[1, 2] | ||
{type: row.type.to_sym, label: label.to_sym, properties: [property.to_sym], state: row.state.to_sym} | ||
end | ||
end | ||
|
||
def constraints(session) | ||
result = query(session, 'CALL db.indexes()', {}, skip_instrumentation: true) | ||
|
||
result.select { |row| row.type == 'node_unique_property' }.map do |row| | ||
label, property = row.description.match(/INDEX ON :([^\(]+)\(([^\)]+)\)/)[1, 2] | ||
{type: :uniqueness, label: label.to_sym, properties: [property.to_sym]} | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module Neo4jSpecHelpers | ||
class << self | ||
attr_accessor :expect_queries_count | ||
end | ||
|
||
self.expect_queries_count = 0 | ||
|
||
Neo4j::Core::CypherSession::Adaptors::Base.subscribe_to_query do |_message| | ||
self.expect_queries_count += 1 | ||
end | ||
|
||
def expect_queries(count) | ||
start_count = Neo4jSpecHelpers.expect_queries_count | ||
yield | ||
expect(Neo4jSpecHelpers.expect_queries_count - start_count).to eq(count) | ||
end | ||
|
||
def delete_schema(session = nil) | ||
Neo4j::Core::Label.drop_uniqueness_constraints_for(session || current_session) | ||
Neo4j::Core::Label.drop_indexes_for(session || current_session) | ||
end | ||
|
||
def create_constraint(session, label_name, property, options = {}) | ||
label_object = Neo4j::Core::Label.new(label_name, session) | ||
label_object.create_constraint(property, options) | ||
end | ||
|
||
def create_index(session, label_name, property, options = {}) | ||
label_object = Neo4j::Core::Label.new(label_name, session) | ||
label_object.create_index(property, options) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters