activerecord-multi-tenant 2.1.4 → 2.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/CI.yml +0 -10
- data/CHANGELOG.md +3 -0
- data/lib/activerecord-multi-tenant/query_rewriter.rb +3 -2
- data/lib/activerecord-multi-tenant/version.rb +1 -1
- data/spec/activerecord-multi-tenant/model_extensions_spec.rb +49 -0
- metadata +2 -4
- data/gemfiles/active_record_5.2.3.gemfile +0 -16
- data/gemfiles/rails_5.2.3.gemfile +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb96e241668d1b08b01d087f2223f7ae703a73e09412f67aadb297aa0bb43818
|
4
|
+
data.tar.gz: f8e964e5549e489c93baaf0ce61b150eac3f3bb7c327dbec7994288c096a535c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5746bb54fb98adf017c0c888b6993a2e82fcca9a0f56588e405230bc1750c63723f89b9664b8f2d31dc11cbd43a1ee43a9d4e39f1ba784f4f9fc09450245833c
|
7
|
+
data.tar.gz: 448dda3c1b4406afe5aa602aa965bc5be35b18cbd539f8cd28fdd626ea00b65970d993fe6ae637ffeca3c809c43ab556ae2fdfdadcac853923b3222e798c6dc1
|
data/.github/workflows/CI.yml
CHANGED
@@ -19,12 +19,10 @@ jobs:
|
|
19
19
|
- '3.0'
|
20
20
|
- '3.1'
|
21
21
|
gemfile:
|
22
|
-
- rails_5.2.3
|
23
22
|
- rails_5.2
|
24
23
|
- rails_6.0
|
25
24
|
- rails_6.1
|
26
25
|
- rails_7.0
|
27
|
-
- active_record_5.2.3
|
28
26
|
- active_record_5.2
|
29
27
|
- active_record_6.0
|
30
28
|
- active_record_6.1
|
@@ -49,14 +47,6 @@ jobs:
|
|
49
47
|
gemfile: 'rails_5.2'
|
50
48
|
- ruby: '3.1'
|
51
49
|
gemfile: 'active_record_5.2'
|
52
|
-
- ruby: '3.0'
|
53
|
-
gemfile: 'rails_5.2.3'
|
54
|
-
- ruby: '3.0'
|
55
|
-
gemfile: 'active_record_5.2.3'
|
56
|
-
- ruby: '3.1'
|
57
|
-
gemfile: 'rails_5.2.3'
|
58
|
-
- ruby: '3.1'
|
59
|
-
gemfile: 'active_record_5.2.3'
|
60
50
|
name: Ruby ${{ matrix.ruby }} / ${{ matrix.gemfile }} ${{ (matrix.prepared_statements && 'w/ prepared statements') || '' }}
|
61
51
|
env:
|
62
52
|
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 2.1.5 2022-11-20
|
4
|
+
* Fix `MultiTenant.without` codegen bug in Rails 6.1+ [#168](https://github.com/citusdata/activerecord-multi-tenant/pull/168)
|
5
|
+
|
3
6
|
## 2.1.4 2022-11-03
|
4
7
|
* Fixes #166 where db:schema:dump is broken when using this gem with MySQL [#167](https://github.com/citusdata/activerecord-multi-tenant/pull/167)
|
5
8
|
|
@@ -330,8 +330,9 @@ module ActiveRecord
|
|
330
330
|
return nil, nil
|
331
331
|
end
|
332
332
|
|
333
|
-
|
334
|
-
|
333
|
+
child = children.first.respond_to?(:children) ? children.first.children.first : children.first
|
334
|
+
if child.right.respond_to?(:relation) && child.left.respond_to?(:relation)
|
335
|
+
return child.right.relation, child.left.relation
|
335
336
|
end
|
336
337
|
|
337
338
|
return nil, nil
|
@@ -299,6 +299,55 @@ describe MultiTenant do
|
|
299
299
|
end
|
300
300
|
end
|
301
301
|
|
302
|
+
# Joins
|
303
|
+
describe 'joins for models' do
|
304
|
+
context 'for models with where condition in associations' do
|
305
|
+
let(:account) { Account.create!(name: 'Account 1') }
|
306
|
+
|
307
|
+
it 'should add tenant condition to the queries when tenant is set' do
|
308
|
+
expected_join_sql = <<-SQL.strip
|
309
|
+
SELECT "comments".* FROM "comments" INNER JOIN "tasks" ON "tasks"."id" = "comments"."commentable_id" AND "comments"."commentable_type" = 'Task' AND "tasks"."account_id" = 1 WHERE "comments"."account_id" = 1
|
310
|
+
SQL
|
311
|
+
|
312
|
+
MultiTenant.with(account) do
|
313
|
+
expect(Comment.joins(:task).to_sql).to eq(expected_join_sql)
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
it 'should add tenant condition to the queries when tenant is not set' do
|
318
|
+
MultiTenant.without do
|
319
|
+
expected_join_sql = <<-SQL.strip
|
320
|
+
SELECT "comments".* FROM "comments" INNER JOIN "tasks" ON "tasks"."id" = "comments"."commentable_id" AND "comments"."commentable_type" = 'Task' AND "comments"."account_id" = "tasks"."account_id"
|
321
|
+
SQL
|
322
|
+
expect(Comment.joins(:task).to_sql).to eq(expected_join_sql)
|
323
|
+
end
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
context 'for models with default associations' do
|
328
|
+
let(:account) { Account.create!(name: 'Account 1') }
|
329
|
+
|
330
|
+
it 'should add tenant condition to the queries when tenant is set' do
|
331
|
+
expected_join_sql = <<-SQL.strip
|
332
|
+
SELECT "projects".* FROM "projects" INNER JOIN "tasks" ON "tasks"."project_id" = "projects"."id" AND "tasks"."account_id" = 1 WHERE "projects"."account_id" = 1
|
333
|
+
SQL
|
334
|
+
|
335
|
+
MultiTenant.with(account) do
|
336
|
+
expect(Project.joins(:tasks).to_sql).to eq(expected_join_sql)
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
it 'should add tenant condition to the queries when tenant is not set' do
|
341
|
+
MultiTenant.without do
|
342
|
+
expected_join_sql = <<-SQL.strip
|
343
|
+
SELECT "projects".* FROM "projects" INNER JOIN "tasks" ON "tasks"."project_id" = "projects"."id" AND "projects"."account_id" = "tasks"."account_id"
|
344
|
+
SQL
|
345
|
+
expect(Project.joins(:tasks).to_sql).to eq(expected_join_sql)
|
346
|
+
end
|
347
|
+
end
|
348
|
+
end
|
349
|
+
end
|
350
|
+
|
302
351
|
# ::with
|
303
352
|
describe "::with" do
|
304
353
|
it "should set current_tenant to the specified tenant inside the block" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-multi-tenant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Citus Data
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-11-
|
11
|
+
date: 2022-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -154,12 +154,10 @@ files:
|
|
154
154
|
- activerecord-multi-tenant.gemspec
|
155
155
|
- docker-compose.yml
|
156
156
|
- gemfiles/.bundle/config
|
157
|
-
- gemfiles/active_record_5.2.3.gemfile
|
158
157
|
- gemfiles/active_record_5.2.gemfile
|
159
158
|
- gemfiles/active_record_6.0.gemfile
|
160
159
|
- gemfiles/active_record_6.1.gemfile
|
161
160
|
- gemfiles/active_record_7.0.gemfile
|
162
|
-
- gemfiles/rails_5.2.3.gemfile
|
163
161
|
- gemfiles/rails_5.2.gemfile
|
164
162
|
- gemfiles/rails_6.0.gemfile
|
165
163
|
- gemfiles/rails_6.1.gemfile
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "appraisal"
|
6
|
-
gem "activerecord", "~> 5.2.0", "< 5.2.4" # FIXME
|
7
|
-
gem "i18n", "~> 0.9.5"
|
8
|
-
gem "nokogiri", "~> 1.7.1"
|
9
|
-
gem "nio4r", "~> 2.3.1"
|
10
|
-
gem "sprockets", "~> 3.7.1"
|
11
|
-
gem "byebug", "~> 11.0"
|
12
|
-
gem "rake", "12.0.0"
|
13
|
-
gem "redis", "3.3.3"
|
14
|
-
gem "pry-byebug", "3.9.0"
|
15
|
-
|
16
|
-
gemspec path: "../"
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "appraisal"
|
6
|
-
gem "rails", "~> 5.2.0", "< 5.2.4" # FIXME
|
7
|
-
gem "i18n", "~> 0.9.5"
|
8
|
-
gem "nokogiri", "~> 1.7.1"
|
9
|
-
gem "nio4r", "~> 2.3.1"
|
10
|
-
gem "sprockets", "~> 3.7.1"
|
11
|
-
gem "byebug", "~> 11.0"
|
12
|
-
gem "rake", "12.0.0"
|
13
|
-
gem "redis", "3.3.3"
|
14
|
-
gem "pry-byebug", "3.9.0"
|
15
|
-
|
16
|
-
gemspec path: "../"
|