Skip to content

Commit

Permalink
Don't fail schema inspection when legacy indexes exist
Browse files Browse the repository at this point in the history
  • Loading branch information
imustafin committed Jan 22, 2020
1 parent b85a763 commit 3839629
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/neo4j/core/cypher_session/adaptors/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,24 @@ 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]
match = row.description.match(/INDEX ON :([^\(]+)\(([^\)]+)\)/)
next unless match

label, property = match[1, 2]
{type: row.type.to_sym, label: label.to_sym, properties: [property.to_sym], state: row.state.to_sym}
end
end.compact
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]
match = row.description.match(/INDEX ON :([^\(]+)\(([^\)]+)\)/)
next unless match

label, property = match[1, 2]
{type: :uniqueness, label: label.to_sym, properties: [property.to_sym]}
end
end.compact
end
end
end
Expand Down

0 comments on commit 3839629

Please sign in to comment.