Make sure syntax doesn’t throw error in SQLite

This commit is contained in:
Brian Hempel 2014-09-01 15:57:19 -04:00
parent 1ad82d27c0
commit db1e335ac2
3 changed files with 5 additions and 2 deletions

View File

@ -19,7 +19,7 @@ module ActiveRecord
end
private
def verify_union_relations!(*args)
includes_relations = args.select { |r| r.includes_values.any? }
if includes_relations.any?

View File

@ -7,7 +7,8 @@ end
class Post < ActiveRecord::Base
connection.create_table :posts, force: true do |t|
t.integer :user_id
t.integer :user_id
t.timestamp :published_at
t.timestamps
end

View File

@ -31,6 +31,7 @@ describe ActiveRecord::Relation do
expect(union.to_sql).to eq(
"SELECT \"posts\".* FROM ( SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = ? UNION SELECT \"posts\".* FROM \"posts\" WHERE (created_at > '2014-07-19 00:00:00.000000') ) posts"
)
expect{union.to_a}.to_not raise_error
end
it "binds values properly" do
@ -57,6 +58,7 @@ describe ActiveRecord::Relation do
expect(union.to_sql).to eq(
"SELECT \"posts\".* FROM ( SELECT \"posts\".* FROM \"posts\" WHERE (published_at < '2014-07-24 00:00:00.000000') AND (created_at > '2014-07-19 00:00:00.000000') UNION SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = ? ) posts"
)
expect{union.to_a}.to_not raise_error
end
context "builds a scope when given" do