lib/puppetdb/astnode.rb in ruby-puppetdb-1.4.0 vs lib/puppetdb/astnode.rb in ruby-puppetdb-1.5.0
- old
+ new
@@ -13,17 +13,24 @@
return self
end
# Generate the the query code for a subquery
#
+ # As a special case, the from_mode of :none will not wrap the
+ # subquery at all, returning it as is.
+ #
# @param from_mode [Symbol] the mode you want to subquery from
# @param to_mode [Symbol] the mode you want to subquery to
# @param query the query inside the subquery
# @return [Array] the resulting subquery
def subquery(from_mode, to_mode, query)
- return ['in', (from_mode == :nodes) ? 'name' : 'certname',
- ['extract', (to_mode == :nodes) ? 'name' : 'certname',
- ["select-#{to_mode.to_s}", query]]]
+ if from_mode == :none
+ return query
+ else
+ return ['in', (from_mode == :nodes) ? 'name' : 'certname',
+ ['extract', (to_mode == :nodes) ? 'name' : 'certname',
+ ["select-#{to_mode.to_s}", query]]]
+ end
end
# Go through the AST and optimize boolean expressions into triplets etc
# Changes the AST in place
#