mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
IN seems to work
This commit is contained in:
parent
d12580a7ee
commit
4146538dfd
5 changed files with 30 additions and 7 deletions
|
@ -7,11 +7,23 @@ module Arel
|
|||
it 'should return an equality node' do
|
||||
attribute = Attribute.new nil, nil, nil
|
||||
equality = attribute.eq 1
|
||||
equality.left.should == attribute
|
||||
equality.right.should == 1
|
||||
check equality.left.should == attribute
|
||||
check equality.right.should == 1
|
||||
equality.should be_kind_of Nodes::Equality
|
||||
end
|
||||
end
|
||||
|
||||
describe '#in' do
|
||||
it 'can be constructed with a list' do
|
||||
end
|
||||
|
||||
it 'should return an in node' do
|
||||
attribute = Attribute.new nil, nil, nil
|
||||
node = Nodes::In.new attribute, [1,2,3]
|
||||
check node.left.should == attribute
|
||||
check node.right.should == [1, 2, 3]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'equality' do
|
||||
|
|
|
@ -127,7 +127,7 @@ module Arel
|
|||
it "chains" do
|
||||
table = Table.new :users
|
||||
manager = Arel::SelectManager.new Table.engine
|
||||
manager.from(table).project(table['id']).should == manager
|
||||
check manager.from(table).project(table['id']).should == manager
|
||||
manager.to_sql.should be_like 'SELECT "users"."id" FROM "users"'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,12 +9,12 @@ module Arel
|
|||
describe 'new' do
|
||||
it 'should accept an engine' do
|
||||
rel = Table.new :users, 'foo'
|
||||
rel.engine.should == 'foo'
|
||||
check rel.engine.should == 'foo'
|
||||
end
|
||||
|
||||
it 'should accept a hash' do
|
||||
rel = Table.new :users, :engine => 'foo'
|
||||
rel.engine.should == 'foo'
|
||||
check rel.engine.should == 'foo'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -44,7 +44,7 @@ module Arel
|
|||
describe 'columns' do
|
||||
it 'returns a list of columns' do
|
||||
columns = @relation.columns
|
||||
columns.length.should == 2
|
||||
check columns.length.should == 2
|
||||
columns.map { |x| x.name }.sort.should == %w{ name id }.sort
|
||||
end
|
||||
end
|
||||
|
@ -61,7 +61,7 @@ module Arel
|
|||
describe 'when given a', Symbol do
|
||||
it "manufactures an attribute if the symbol names an attribute within the relation" do
|
||||
column = @relation[:id]
|
||||
column.name.should == 'id'
|
||||
check column.name.should == 'id'
|
||||
column.should be_kind_of Attributes::Integer
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,6 +13,15 @@ module Arel
|
|||
@visitor.accept attr
|
||||
end
|
||||
|
||||
describe "Nodes::In" do
|
||||
it "should know how to visit" do
|
||||
node = @attr.in [1, 2, 3]
|
||||
@visitor.accept(node).should be_like %{
|
||||
"users"."id" IN (1, 2, 3)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Equality' do
|
||||
it "should escape strings" do
|
||||
test = @attr.eq 'Aaron Patterson'
|
||||
|
|
|
@ -4,6 +4,7 @@ require 'fileutils'
|
|||
require 'arel'
|
||||
|
||||
require 'support/matchers/be_like'
|
||||
require 'support/check'
|
||||
|
||||
if adapter = ENV['ADAPTER']
|
||||
require "support/connections/#{adapter}_connection.rb"
|
||||
|
@ -11,6 +12,7 @@ end
|
|||
|
||||
Spec::Runner.configure do |config|
|
||||
config.include Matchers
|
||||
config.include Check
|
||||
|
||||
if defined?(ActiveRecord::Base)
|
||||
tmp = File.expand_path('../../tmp', __FILE__)
|
||||
|
|
Loading…
Reference in a new issue