spec/engines/sql/unit/predicates/in_spec.rb in arel-0.3.3 vs spec/engines/sql/unit/predicates/in_spec.rb in arel-0.4.0
- old
+ new
@@ -98,10 +98,32 @@
sql.should be_like(%Q{"users"."id" BETWEEN 1 AND 2})
end
end
end
+ describe 'when relating to a range with an excluded end' do
+ before do
+ @range = 1...3
+ end
+
+ it 'manufactures sql with a >= and <' do
+ sql = In.new(@attribute, @range).to_sql
+
+ adapter_is :mysql do
+ sql.should be_like(%Q{(`users`.`id` >= 1 AND `users`.`id` < 3)})
+ end
+
+ adapter_is :oracle do
+ sql.should be_like(%Q{("USERS"."ID" >= 1 AND "USERS"."ID" < 3)})
+ end
+
+ adapter_is_not :mysql, :oracle do
+ sql.should be_like(%Q{("users"."id" >= 1 AND "users"."id" < 3)})
+ end
+ end
+ end
+
describe 'when relating to a time range' do
before do
@relation = Arel::Table.new(:developers)
@attribute = @relation[:created_at]
@range = Time.mktime(2010, 01, 01)..Time.mktime(2010, 02, 01)
@@ -113,14 +135,10 @@
adapter_is :mysql do
sql.should be_like(%Q{`developers`.`created_at` BETWEEN '2010-01-01 00:00:00' AND '2010-02-01 00:00:00'})
end
adapter_is :sqlite3 do
- if RUBY_VERSION < '1.9'
- sql.should be_like(%Q{"developers"."created_at" BETWEEN '2010-01-01 00:00:00.000000' AND '2010-02-01 00:00:00.000000'})
- else
- sql.should be_like(%Q{"developers"."created_at" BETWEEN '2010-01-01 00:00:00' AND '2010-02-01 00:00:00'})
- end
+ sql.should match(/"developers"."created_at" BETWEEN '2010-01-01 00:00:00(?:\.\d+)' AND '2010-02-01 00:00:00(?:\.\d+)'/)
end
adapter_is :postgresql do
sql.should be_like(%Q{"developers"."created_at" BETWEEN '2010-01-01 00:00:00.000000' AND '2010-02-01 00:00:00.000000'})
end