Class: FluentQuery::Drivers::Shared::Tokens::SQL::Set
- Inherits:
-
FluentQuery::Drivers::Shared::Tokens::SQLToken
- Object
- FluentQuery::Drivers::Shared::Tokens::SQLToken
- FluentQuery::Drivers::Shared::Tokens::SQL::Set
- Defined in:
- lib/fluent-query/drivers/shared/tokens/sql/set.rb
Overview
Generic SQL query SET 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 = :build) ⇒ Object
23 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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/fluent-query/drivers/shared/tokens/sql/set.rb', line 23 def render!(mode = :build) _class = self.unknown_token stack = [ ] unknown = [ ] operator = @_driver.quote_operator(:and) processor = @_query.processor result = "SET " @_subtokens.each do |token| arguments = token.arguments # SET token if token.name == :set length = arguments.length # Checks for arguments if length > 0 if (length > 1) or (arguments.first.string?) stack << processor.process_formatted(arguments, mode) elsif arguments.first.hash? stack << processor.process_hash(arguments.first, ", ", :assigning) end else raise FluentQuery::Drivers::Exception::new("SET token expects Hash or formatted string as argument.") end # Unknown tokens renders directly else result << _class::new(@_driver, @_query, [token]).render! end end # Closes opened native token with unknown tokens if unknown.length > 0 native = _class::new(@_driver, @_query, unknown) stack << native unknown = [ ] end # Process stack with results first = true stack.each do |item| if item.kind_of? _class result << item.render! elsif item.string? if not first result << operator << " " else first = false end result << item end result << " " end return result end |