Class: Cyrel::Expression::ExistsBlock
- Defined in:
- lib/cyrel/expression/exists.rb
Overview
Represents an EXISTS { MATCH … WHERE … } subquery predicate (Memgraph 3.5+). Allows full subquery syntax inside EXISTS block.
Instance Attribute Summary collapse
-
#subquery ⇒ Object
readonly
Returns the value of attribute subquery.
Instance Method Summary collapse
-
#initialize(subquery) ⇒ ExistsBlock
constructor
A new instance of ExistsBlock.
-
#render(query) ⇒ String
Renders the EXISTS { … } expression.
Methods inherited from Base
#!=, #%, #&, #*, #+, #-, #/, #<, #<=, #==, #=~, #>, #>=, #^, #|
Constructor Details
#initialize(subquery) ⇒ ExistsBlock
Returns a new instance of ExistsBlock.
49 50 51 52 53 |
# File 'lib/cyrel/expression/exists.rb', line 49 def initialize(subquery) raise ArgumentError, 'ExistsBlock requires a Cyrel::Query' unless subquery.is_a?(Cyrel::Query) @subquery = subquery end |
Instance Attribute Details
#subquery ⇒ Object (readonly)
Returns the value of attribute subquery.
46 47 48 |
# File 'lib/cyrel/expression/exists.rb', line 46 def subquery @subquery end |
Instance Method Details
#render(query) ⇒ String
Renders the EXISTS { … } expression.
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/cyrel/expression/exists.rb', line 58 def render(query) inner_cypher, inner_params = @subquery.to_cypher # Merge subquery parameters into the parent query # The inner query uses its own parameter keys, we need to register values # which will get new keys in the parent query inner_params.each_value do |value| query.register_parameter(value) end "EXISTS { #{inner_cypher} }" end |