Class: Cyrel::Clause::CallSubquery
- Defined in:
- lib/cyrel/clause/call_subquery.rb
Overview
Represents a CALL { subquery } clause.
Instance Attribute Summary collapse
-
#subquery ⇒ Object
readonly
Returns the value of attribute subquery.
Instance Method Summary collapse
-
#initialize(subquery) ⇒ CallSubquery
constructor
A new instance of CallSubquery.
-
#render(_outer_query) ⇒ String
Renders the CALL { subquery } clause.
Constructor Details
#initialize(subquery) ⇒ CallSubquery
Returns a new instance of CallSubquery.
10 11 12 13 14 15 |
# File 'lib/cyrel/clause/call_subquery.rb', line 10 def initialize(subquery) super() # Call super for Base initialization raise ArgumentError, "Subquery must be a Cyrel::Query instance, got #{subquery.class}" unless subquery.is_a?(Cyrel::Query) @subquery = subquery end |
Instance Attribute Details
#subquery ⇒ Object (readonly)
Returns the value of attribute subquery.
7 8 9 |
# File 'lib/cyrel/clause/call_subquery.rb', line 7 def subquery @subquery end |
Instance Method Details
#render(_outer_query) ⇒ String
Renders the CALL { subquery } clause. Note: Parameter merging between outer and inner queries needs careful handling. This basic implementation assumes parameters are managed separately or the outer query’s #merge! handles parameter transfer if the subquery was built and then passed in.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cyrel/clause/call_subquery.rb', line 24 def render(_outer_query) # We need the subquery's cypher string and parameters. # Parameters from the subquery need to be merged into the outer query. # This is complex. For now, let's assume parameters are handled externally # or the subquery doesn't introduce new parameters conflicting with the outer scope. # A more robust solution would involve the outer query managing all parameters. sub_cypher, _sub_params = @subquery.to_cypher indented_sub_cypher = sub_cypher.gsub(/^/, ' ') # Indent subquery "CALL {\n#{indented_sub_cypher}\n}" # Construct final string # Return final string end |