activerecord-multi-tenant 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +2 -2
- data/gemfiles/rails_3.2.gemfile.lock +2 -2
- data/gemfiles/rails_4.0.gemfile.lock +2 -2
- data/gemfiles/rails_4.1.gemfile.lock +2 -2
- data/gemfiles/rails_4.2.gemfile.lock +2 -2
- data/gemfiles/rails_5.0.gemfile.lock +2 -2
- data/lib/activerecord-multi-tenant/referential_integrity.rb +6 -8
- data/lib/activerecord-multi-tenant/version.rb +1 -1
- data/lib/activerecord-multi-tenant/with_lock.rb +7 -9
- data/spec/activerecord-multi-tenant/model_extensions_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 261f0a075c9a14524dfc43455a030e710bd140a1
|
4
|
+
data.tar.gz: 3bdd3d5ef7aec6fa07d67a8226a600accb3eeadd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b2c5621e0de6308ebc36169873318fd4975e7b54ae7e409a05d58978f65407e8ef6e99e82e2f7399dafdfb659421123cb849e825b93426c28e742ea4ff434a8
|
7
|
+
data.tar.gz: 0ced6530c9654b4dcfc4d326d6c97a1225d4a47b2300221a8b2fbf05ec3243fc27af128b9da975c73053d23235c333ff79fd10aaf378f7c0f3fb0c844395b4f0
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.3.4 2017-02-22
|
4
|
+
|
5
|
+
* Expand with_lock workaround to cover lock! as well
|
6
|
+
* Enable trigger workaround on Rails 5 as well, otherwise it fails silently
|
7
|
+
* Tests: Switch to database cleaner truncation strategy to avoid multi-shard transactions
|
8
|
+
|
9
|
+
|
3
10
|
## 0.3.3 2017-02-21
|
4
11
|
|
5
12
|
* Avoid warning about multi-column primary keys with Rails 5 [#2](https://github.com/citusdata/activerecord-multi-tenant/issues/2)
|
data/Gemfile.lock
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
# Workaround for https://github.com/citusdata/citus/issues/1080
|
2
2
|
# "Support DISABLE/ENABLE TRIGGER ALL on distributed tables"
|
3
3
|
|
4
|
-
|
5
|
-
require 'active_record/connection_adapters/postgresql_adapter'
|
4
|
+
require 'active_record/connection_adapters/postgresql_adapter'
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
6
|
+
module ActiveRecord
|
7
|
+
module ConnectionAdapters
|
8
|
+
class PostgreSQLAdapter < AbstractAdapter
|
9
|
+
def supports_disable_referential_integrity?
|
10
|
+
false
|
13
11
|
end
|
14
12
|
end
|
15
13
|
end
|
@@ -2,16 +2,14 @@
|
|
2
2
|
# "SELECT ... FOR UPDATE is not supported for router-plannable queries"
|
3
3
|
|
4
4
|
class ActiveRecord::Base
|
5
|
-
alias :
|
6
|
-
def
|
7
|
-
if self.class.respond_to?(:scoped_by_tenant?) && MultiTenant.current_tenant_id && MultiTenant.with_lock_workaround_enabled?
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
yield
|
12
|
-
end
|
5
|
+
alias :lock_orig :lock!
|
6
|
+
def lock!(lock = true)
|
7
|
+
if lock && persisted? && self.class.respond_to?(:scoped_by_tenant?) && MultiTenant.current_tenant_id && MultiTenant.with_lock_workaround_enabled?
|
8
|
+
self.class.unscoped.where(id: id).update_all(id: id) # No-op UPDATE that locks the row
|
9
|
+
reload # This is just to act similar to the default Rails approach, in case someone relies on the reload
|
10
|
+
self
|
13
11
|
else
|
14
|
-
|
12
|
+
lock_orig(lock)
|
15
13
|
end
|
16
14
|
end
|
17
15
|
end
|
@@ -159,7 +159,7 @@ describe MultiTenant do
|
|
159
159
|
expect(MultiTenant.current_tenant).to eq(@account1)
|
160
160
|
end
|
161
161
|
|
162
|
-
it "should return the value of the block"
|
162
|
+
it "should return the value of the block" do
|
163
163
|
@account1 = Account.create!(:name => 'foo')
|
164
164
|
@account2 = Account.create!(:name => 'bar')
|
165
165
|
|
data/spec/spec_helper.rb
CHANGED
@@ -21,8 +21,8 @@ RSpec.configure do |config|
|
|
21
21
|
end
|
22
22
|
|
23
23
|
config.before(:suite) do
|
24
|
-
DatabaseCleaner[:active_record].strategy = :
|
25
|
-
DatabaseCleaner[:active_record].
|
24
|
+
DatabaseCleaner[:active_record].strategy = :truncation
|
25
|
+
DatabaseCleaner[:active_record].clean
|
26
26
|
|
27
27
|
# Keep this here until https://github.com/citusdata/citus/issues/1236 is fixed in a patch release we can run tests with
|
28
28
|
MultiTenant.enable_with_lock_workaround
|