Class: FluentQuery::Drivers::Shared::Tokens::SQLToken
- Inherits:
-
Object
- Object
- FluentQuery::Drivers::Shared::Tokens::SQLToken
- Defined in:
- lib/fluent-query/drivers/shared/tokens/sql.rb
Overview
PostgreSQL query native token.
Direct Known Subclasses
FluentQuery::Drivers::Shared::Tokens::SQL::Delete, FluentQuery::Drivers::Shared::Tokens::SQL::From, FluentQuery::Drivers::Shared::Tokens::SQL::GroupBy, FluentQuery::Drivers::Shared::Tokens::SQL::Having, FluentQuery::Drivers::Shared::Tokens::SQL::Insert, FluentQuery::Drivers::Shared::Tokens::SQL::Join, FluentQuery::Drivers::Shared::Tokens::SQL::OrderBy, FluentQuery::Drivers::Shared::Tokens::SQL::Select, FluentQuery::Drivers::Shared::Tokens::SQL::Set, FluentQuery::Drivers::Shared::Tokens::SQL::Truncate, FluentQuery::Drivers::Shared::Tokens::SQL::Union, FluentQuery::Drivers::Shared::Tokens::SQL::Update, FluentQuery::Drivers::Shared::Tokens::SQL::Where
Constant Summary collapse
- TRANSFORMER =
Holds token transformer.
/([A-Z])/
Instance Method Summary collapse
-
#initialize(driver, query, subtokens) ⇒ SQLToken
constructor
A new instance of SQLToken.
- #render!(mode = :build) ⇒ Object
Constructor Details
#initialize(driver, query, subtokens) ⇒ SQLToken
Returns a new instance of SQLToken.
44 45 46 47 48 |
# File 'lib/fluent-query/drivers/shared/tokens/sql.rb', line 44 def initialize(driver, query, subtokens) @_query = query @_driver = driver @_subtokens = subtokens end |
Instance Method Details
#render!(mode = :build) ⇒ Object
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 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/fluent-query/drivers/shared/tokens/sql.rb', line 62 def render!(mode = :build) result = "" processor = @_query.processor # Transforms all subtokens to real string SQL tokens @_subtokens.each do |token| arguments = token.arguments name = token.name transformed = self._transform_token(name.to_s) operator = @_driver.operator_token? name if operator glue = transformed else glue = "," end first = arguments.first if first.array? arguments_result = processor.process_array(first, glue) elsif first.hash? arguments_result = processor.process_hash(first, glue) elsif first.symbol? arguments_result = processor.process_identifiers(arguments) else arguments_result = processor.process_formatted(arguments, mode) end result << transformed << " " << arguments_result << " " end return result end |