diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-12-28 10:45:11 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-12-28 10:45:11 -0300 |
commit | 4fe6bdf195336d54b082ca26b96c5294d8aae3d1 (patch) | |
tree | b806cb6416b57a1efcc65ba9b30dc20cd6fe3a77 | |
parent | b339caca2f3c7306c3944c5fc5d8dde17ae2deb8 (diff) | |
download | rails-4fe6bdf195336d54b082ca26b96c5294d8aae3d1.tar.gz rails-4fe6bdf195336d54b082ca26b96c5294d8aae3d1.tar.bz2 rails-4fe6bdf195336d54b082ca26b96c5294d8aae3d1.zip |
Don't try to lock reads when using any SQLite adapter, it's redundant
and may generate an invalid query.
-rw-r--r-- | lib/arel/engines/sql/relations/relation.rb | 2 | ||||
-rw-r--r-- | spec/arel/engines/sql/unit/relations/lock_spec.rb | 18 |
2 files changed, 17 insertions, 3 deletions
diff --git a/lib/arel/engines/sql/relations/relation.rb b/lib/arel/engines/sql/relations/relation.rb index 8b71aa8c04..12b328151f 100644 --- a/lib/arel/engines/sql/relations/relation.rb +++ b/lib/arel/engines/sql/relations/relation.rb @@ -35,7 +35,7 @@ module Arel ("ORDER BY #{order_clauses.join(', ')}" unless orders.blank? ), ("LIMIT #{taken}" unless taken.blank? ), ("OFFSET #{skipped}" unless skipped.blank? ), - ("#{locked}" unless locked.blank? ) + ("#{locked}" unless engine.adapter_name =~ /SQLite/ || locked.blank?) end end diff --git a/spec/arel/engines/sql/unit/relations/lock_spec.rb b/spec/arel/engines/sql/unit/relations/lock_spec.rb index 27239eb1a8..23f8a9f577 100644 --- a/spec/arel/engines/sql/unit/relations/lock_spec.rb +++ b/spec/arel/engines/sql/unit/relations/lock_spec.rb @@ -17,12 +17,19 @@ module Arel }) end - adapter_is_not :mysql do + adapter_is :postgresql do sql.should be_like(%Q{ SELECT "users"."id", "users"."name" FROM "users" FOR UPDATE }) end + + adapter_is :sqlite3 do + sql.should be_like(%Q{ + SELECT "users"."id", "users"."name" + FROM "users" + }) + end end it "manufactures a select query locking with a given lock" do @@ -35,12 +42,19 @@ module Arel }) end - adapter_is_not :mysql do + adapter_is :postgresql do sql.should be_like(%Q{ SELECT "users"."id", "users"."name" FROM "users" LOCK IN SHARE MODE }) end + + adapter_is :sqlite3 do + sql.should be_like(%Q{ + SELECT "users"."id", "users"."name" + FROM "users" + }) + end end end end |