Sha256: f7ffd0f2e3e9d0428c91d40fffe42528e20336afd6f2df4b4af19db41d05547f

Contents?: true

Size: 523 Bytes

Versions: 1

Compression:

Stored size: 523 Bytes

Contents

module SQLTree::Node

  class Assignment < Base
    
    attr_accessor :field, :expression
    
    def initialize(field, expression = nil)
      @field, @expression = field, expression
    end
    
    def to_sql
      "#{quote_var(field)} = #{expression.to_sql}"
    end
    
    def self.parse(tokens)
      assignment = self.new(SQLTree::Node::Variable.parse(tokens).name)
      tokens.consume(SQLTree::Token::EQ)
      assignment.expression = SQLTree::Node::Expression.parse(tokens)
      assignment
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sql_tree-0.1.0 lib/sql_tree/node/assignment.rb