activecypher 0.7.3 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/lib/active_cypher/connection_adapters/memgraph_adapter.rb +10 -1
  3. data/lib/active_cypher/connection_adapters/neo4j_adapter.rb +1 -1
  4. data/lib/active_cypher/connection_adapters/persistence_methods.rb +31 -14
  5. data/lib/active_cypher/relation.rb +1 -1
  6. data/lib/active_cypher/version.rb +1 -1
  7. data/lib/activecypher.rb +3 -1
  8. data/lib/cyrel/ast/call_node.rb +39 -0
  9. data/lib/cyrel/ast/clause_adapter.rb +38 -0
  10. data/lib/cyrel/ast/clause_node.rb +10 -0
  11. data/lib/cyrel/ast/compiler.rb +609 -0
  12. data/lib/cyrel/ast/create_node.rb +21 -0
  13. data/lib/cyrel/ast/delete_node.rb +22 -0
  14. data/lib/cyrel/ast/expression_node.rb +10 -0
  15. data/lib/cyrel/ast/foreach_node.rb +23 -0
  16. data/lib/cyrel/ast/limit_node.rb +21 -0
  17. data/lib/cyrel/ast/literal_node.rb +39 -0
  18. data/lib/cyrel/ast/load_csv_node.rb +24 -0
  19. data/lib/cyrel/ast/match_node.rb +23 -0
  20. data/lib/cyrel/ast/merge_node.rb +23 -0
  21. data/lib/cyrel/ast/node.rb +36 -0
  22. data/lib/cyrel/ast/optimized_nodes.rb +117 -0
  23. data/lib/cyrel/ast/order_by_node.rb +21 -0
  24. data/lib/cyrel/ast/pattern_node.rb +10 -0
  25. data/lib/cyrel/ast/query_integrated_compiler.rb +27 -0
  26. data/lib/cyrel/ast/remove_node.rb +21 -0
  27. data/lib/cyrel/ast/return_node.rb +21 -0
  28. data/lib/cyrel/ast/set_node.rb +20 -0
  29. data/lib/cyrel/ast/simple_cache.rb +50 -0
  30. data/lib/cyrel/ast/skip_node.rb +19 -0
  31. data/lib/cyrel/ast/union_node.rb +22 -0
  32. data/lib/cyrel/ast/unwind_node.rb +20 -0
  33. data/lib/cyrel/ast/where_node.rb +20 -0
  34. data/lib/cyrel/ast/with_node.rb +23 -0
  35. data/lib/cyrel/clause/unwind.rb +71 -0
  36. data/lib/cyrel/expression/literal.rb +9 -2
  37. data/lib/cyrel/expression/property_access.rb +1 -1
  38. data/lib/cyrel/pattern/node.rb +11 -1
  39. data/lib/cyrel/pattern/relationship.rb +21 -13
  40. data/lib/cyrel/query.rb +405 -91
  41. data/lib/cyrel.rb +132 -2
  42. metadata +29 -1
@@ -21,21 +21,29 @@ module Cyrel
21
21
  end
22
22
 
23
23
  def render(query)
24
- arrow =
25
- case direction # Ruby 3.4 pattern match
26
- in Direction::OUT then '->'
27
- in Direction::IN then '<-'
28
- else '-'
24
+ # For anonymous relationships (no alias, no types, no properties, no length)
25
+ # we don't render brackets at all
26
+ if alias_name.nil? && types.empty? && properties.empty? && length.nil?
27
+ case direction
28
+ in Direction::OUT then '-->'
29
+ in Direction::IN then '<--'
30
+ else '--'
29
31
  end
32
+ else
33
+ # Regular relationship with brackets
34
+ core = +'['
35
+ core << alias_name.to_s if alias_name
36
+ core << ':' << Array(types).join('|') unless types.empty?
37
+ core << length_spec
38
+ core << " #{prop_string(query)}" unless properties.empty?
39
+ core << ']'
30
40
 
31
- core = +'['
32
- core << "#{alias_name} " if alias_name
33
- core << ':' << Array(types).join('|') unless types.empty?
34
- core << length_spec
35
- core << " #{prop_string(query)}" unless properties.empty?
36
- core << ']'
37
-
38
- "#{arrow.start_with?('<') ? arrow : '-'}#{core}#{arrow.end_with?('>') ? arrow : '-'}"
41
+ case direction
42
+ in Direction::OUT then "-#{core}->"
43
+ in Direction::IN then "<-#{core}-"
44
+ else "-#{core}-"
45
+ end
46
+ end
39
47
  end
40
48
 
41
49
  private