Class: OracleSqlParser::Util::ParameternizedQuery
- Defined in:
- lib/oracle-sql-parser/util/parameterized_query.rb
Instance Attribute Summary collapse
-
#ast ⇒ Object
readonly
Returns the value of attribute ast.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #assign_parameter(value) ⇒ Object
-
#initialize(original) ⇒ ParameternizedQuery
constructor
A new instance of ParameternizedQuery.
- #to_sql ⇒ Object
Constructor Details
#initialize(original) ⇒ ParameternizedQuery
Returns a new instance of ParameternizedQuery.
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/oracle-sql-parser/util/parameterized_query.rb', line 4 def initialize(original) @index = 0 @params = {} @ast = original.map_ast do |v| case v when OracleSqlParser::Ast::NumberLiteral, OracleSqlParser::Ast::TextLiteral assign_parameter(v) else v end end end |
Instance Attribute Details
#ast ⇒ Object (readonly)
Returns the value of attribute ast.
3 4 5 |
# File 'lib/oracle-sql-parser/util/parameterized_query.rb', line 3 def ast @ast end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
3 4 5 |
# File 'lib/oracle-sql-parser/util/parameterized_query.rb', line 3 def params @params end |
Instance Method Details
#assign_parameter(value) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/oracle-sql-parser/util/parameterized_query.rb', line 21 def assign_parameter(value) name = "a#{@index}" @index += 1 @params[name] = value OracleSqlParser::Ast::Variable[:name =>name] end |