class FluentQuery::Drivers::Shared::Tokens::SQL::Set
Generic SQL
query SET token.
Public Instance Methods
render!(mode = :build)
click to toggle source
Renders this token.
# 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