Class: SQLTree::Node::InsertQuery
- Defined in:
- lib/active_record/turntable/sql_tree_patch.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Base
Class Method Details
.parse_value_list(tokens) ⇒ Object
368 369 370 371 372 373 374 375 376 377 378 379 380 381 |
# File 'lib/active_record/turntable/sql_tree_patch.rb', line 368 def self.parse_value_list(tokens) values = [] tokens.consume(SQLTree::Token::VALUES) tokens.consume(SQLTree::Token::LPAREN) values << parse_list(tokens) tokens.consume(SQLTree::Token::RPAREN) while SQLTree::Token::COMMA === tokens.peek tokens.consume(SQLTree::Token::COMMA) tokens.consume(SQLTree::Token::LPAREN) values << parse_list(tokens) tokens.consume(SQLTree::Token::RPAREN) end values end |
Instance Method Details
#to_sql(options = {}) ⇒ Object
358 359 360 361 362 363 364 365 366 |
# File 'lib/active_record/turntable/sql_tree_patch.rb', line 358 def to_sql( = {}) sql = "INSERT INTO #{table.to_sql()} " sql << "(" + fields.map { |f| f.to_sql() }.join(", ") + ") " if fields sql << "VALUES" sql << values.map do |value| " (" + value.map { |v| v.to_sql() }.join(", ") + ")" end.join(",") sql end |