Sha256: d6f47c92a882f29b710b3fc6e69044139cb4397fc6c09df607e9293f926d7957
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
module SQLTree::Node # The <tt>DeleteQuery</tt> node represents an SQL DELETE query. # # This node has two children: <tt>table</tt> and <tt>where</tt>. class SetQuery < Base # The variable (<tt>SQLTree::Node::Field</tt>) that is being set. child :variable # The <tt>SQLTree::Node::Expression</tt> value that the variable is being # set to. child :value # Initializes a new DeleteQuery instance. def initialize(variable, value) @variable, @value = variable, value end # Generates an SQL DELETE query from this node. def to_sql(options = {}) sql = "SET #{variable.to_sql(options)}" sql << " TO #{value.to_sql(options)}" sql end # Parses a SET query from a stream of tokens. # <tt>tokens</tt>:: The token stream to parse from, which is an instance # of <tt> SQLTree::Parser</tt>. def self.parse(tokens) tokens.consume(SQLTree::Token::SET) variable = SQLTree::Node::Expression::Field.parse(tokens) tokens.consume(SQLTree::Token::TO) value = SQLTree::Node::Expression::Value.parse(tokens) return self.new(variable, value) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sql_tree-0.2.0 | lib/sql_tree/node/set_query.rb |