Class: FluentQuery::Drivers::Shared::Tokens::SQL::Union
- Inherits:
-
FluentQuery::Drivers::Shared::Tokens::SQLToken
- Object
- FluentQuery::Drivers::Shared::Tokens::SQLToken
- FluentQuery::Drivers::Shared::Tokens::SQL::Union
- Defined in:
- lib/fluent-query/drivers/shared/tokens/sql/union.rb
Overview
Generic SQL query UNION token.
Constant Summary
Constants inherited from FluentQuery::Drivers::Shared::Tokens::SQLToken
FluentQuery::Drivers::Shared::Tokens::SQLToken::TRANSFORMER
Instance Method Summary collapse
Methods inherited from FluentQuery::Drivers::Shared::Tokens::SQLToken
Constructor Details
This class inherits a constructor from FluentQuery::Drivers::Shared::Tokens::SQLToken
Instance Method Details
#render!(mode = nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/fluent-query/drivers/shared/tokens/sql/union.rb', line 24 def render!(mode = nil) result = "" @_subtokens.each do |token| arguments = token.arguments # SET token if token.name == :union length = arguments.length # Checks for arguments if length >= 2 queries = [ ] arguments.each do |argument| if argument.string? queries << argument elsif argument.kind_of? FluentQuery::Query queries << argument.build! end end else raise FluentQuery::Drivers::Exception::new("UNION token expects at least two queries or strings as arguments.") end end end # Process stack with results queries.map! { |i| @_driver.quote_subquery(i) } result << queries.join(" UNION ") return result end |