Skip to content

Commit

Permalink
update :unions_with_bind and add :optional_unions_with_bind
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Jul 20, 2022
1 parent 27517e2 commit 05a31f3
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions lib/sparql/client/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -442,16 +442,15 @@ def add_union_with_bind(patterns)
end
end
if options[:unions_with_bind]
include_union = nil
options[:unions_with_bind].each do |union_block, value_bind, var_bind|
buffer << include_union if include_union
buffer << '{'
buffer += serialize_patterns(union_block)
buffer << "BIND (\"#{value_bind}\" as ?#{var_bind.to_s})"
buffer << '}'
include_union = "UNION "
end
buffer << add_union_with_bind(options[:unions_with_bind])
end

if options[:optional_unions_with_bind] && !options[:optional_unions_with_bind].empty?
buffer << 'OPTIONAL {'
buffer << add_union_with_bind(options[:optional_unions_with_bind])
buffer << '}'
end

if options[:optionals]
options[:optionals].each do |patterns|
buffer << 'OPTIONAL {'
Expand Down

0 comments on commit 05a31f3

Please sign in to comment.