Sha256: b60c1d1eb9e6e49ab824a21cfdc4d61b75984ecab3a236b905ef9f242cf2267d

Contents?: true

Size: 913 Bytes

Versions: 1

Compression:

Stored size: 913 Bytes

Contents

require "#{File.dirname(__FILE__)}/../spec_helper"

describe SQLTree::Node::UpdateQuery do

  it "should parse a delete query without WHERE clause correctly" do
    update = SQLTree::Node::UpdateQuery["UPDATE table SET field1 = 1, field2 = 5 - 3"]
    update.table.should == 'table'
    update.updates.should have(2).items
    update.updates[0].field.should == 'field1'
    update.updates[0].expression.should == SQLTree::Node::Value.new(1)
    update.updates[1].field.should == 'field2'
    update.updates[1].expression.should be_kind_of(SQLTree::Node::ArithmeticExpression)
    update.where.should be_nil
  end

  it "should parse a delete query without WHERE clause correctly" do
    update = SQLTree::Node::UpdateQuery["UPDATE table SET field = 1 WHERE id = 17"]
    update.table.should == 'table'
    update.updates.should have(1).item
    update.where.should be_kind_of(SQLTree::Node::Expression)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sql_tree-0.1.0 spec/unit/update_query_spec.rb