pg_rls 0.0.1.4.1 → 0.0.1.4.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa0740a77d93fc9f87723797b3bca421e957a5661e4f82211762e21e9a29e53e
4
- data.tar.gz: 47c18a7af64db89155056eaa370131134581f56769730865bf4c9e7781208ca2
3
+ metadata.gz: 7c49344c7e0967e1afe2cf3f982678fcdae6edec8766fa92ed51f644594be84e
4
+ data.tar.gz: 21812122d43412184edefcc4cbe45ba7a160ff5d335f01de8f4962b20fb6e5e6
5
5
  SHA512:
6
- metadata.gz: c0cfdbfb358da830cabf1fae1406e52d208960331f9a871aef2829a9c18d7d5f31d0e6aa5c0d96942148bb6c64060faa875ec11dfe8dd0d9e2da4d14e41637b0
7
- data.tar.gz: f420cf2bfc326cc3b8404f5059a9e1e6b398c377319939d196539be4e2aa4c43d88d27dfd579ca0ceea71cded49a78956687798a88b788a39c5076f2de88f970
6
+ metadata.gz: f423f4793439745830715c5a6058c3703445185dee9e0219ceb68c09a57dcd728ddc758daa35947fef94c0248b7cf075ba73452c9eb2e4ee79e8d8d344ab78d9
7
+ data.tar.gz: 2ad9bb3bac5e097f708075d44b08755621f2cf8202f6a9894dc7171e5ffd728f072d10f61d9df8aabc72297a453ae065088ddf4e403a16f8bb0fc2e2c1d29f7e
data/Gemfile CHANGED
@@ -4,7 +4,7 @@ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in pg_rls.gemspec
6
6
  gemspec
7
- ruby '3.0.2'
7
+ ruby '3.1.1'
8
8
 
9
9
  gem 'rails', '~> 6.1.4', '>= 6.1.4.1'
10
10
 
data/Gemfile.lock CHANGED
@@ -1,66 +1,66 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pg_rls (0.0.1)
4
+ pg_rls (0.0.1.4.2)
5
5
  bundler (>= 2.2.10)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actioncable (6.1.4.1)
11
- actionpack (= 6.1.4.1)
12
- activesupport (= 6.1.4.1)
10
+ actioncable (6.1.5)
11
+ actionpack (= 6.1.5)
12
+ activesupport (= 6.1.5)
13
13
  nio4r (~> 2.0)
14
14
  websocket-driver (>= 0.6.1)
15
- actionmailbox (6.1.4.1)
16
- actionpack (= 6.1.4.1)
17
- activejob (= 6.1.4.1)
18
- activerecord (= 6.1.4.1)
19
- activestorage (= 6.1.4.1)
20
- activesupport (= 6.1.4.1)
15
+ actionmailbox (6.1.5)
16
+ actionpack (= 6.1.5)
17
+ activejob (= 6.1.5)
18
+ activerecord (= 6.1.5)
19
+ activestorage (= 6.1.5)
20
+ activesupport (= 6.1.5)
21
21
  mail (>= 2.7.1)
22
- actionmailer (6.1.4.1)
23
- actionpack (= 6.1.4.1)
24
- actionview (= 6.1.4.1)
25
- activejob (= 6.1.4.1)
26
- activesupport (= 6.1.4.1)
22
+ actionmailer (6.1.5)
23
+ actionpack (= 6.1.5)
24
+ actionview (= 6.1.5)
25
+ activejob (= 6.1.5)
26
+ activesupport (= 6.1.5)
27
27
  mail (~> 2.5, >= 2.5.4)
28
28
  rails-dom-testing (~> 2.0)
29
- actionpack (6.1.4.1)
30
- actionview (= 6.1.4.1)
31
- activesupport (= 6.1.4.1)
29
+ actionpack (6.1.5)
30
+ actionview (= 6.1.5)
31
+ activesupport (= 6.1.5)
32
32
  rack (~> 2.0, >= 2.0.9)
33
33
  rack-test (>= 0.6.3)
34
34
  rails-dom-testing (~> 2.0)
35
35
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
36
- actiontext (6.1.4.1)
37
- actionpack (= 6.1.4.1)
38
- activerecord (= 6.1.4.1)
39
- activestorage (= 6.1.4.1)
40
- activesupport (= 6.1.4.1)
36
+ actiontext (6.1.5)
37
+ actionpack (= 6.1.5)
38
+ activerecord (= 6.1.5)
39
+ activestorage (= 6.1.5)
40
+ activesupport (= 6.1.5)
41
41
  nokogiri (>= 1.8.5)
42
- actionview (6.1.4.1)
43
- activesupport (= 6.1.4.1)
42
+ actionview (6.1.5)
43
+ activesupport (= 6.1.5)
44
44
  builder (~> 3.1)
45
45
  erubi (~> 1.4)
46
46
  rails-dom-testing (~> 2.0)
47
47
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
48
- activejob (6.1.4.1)
49
- activesupport (= 6.1.4.1)
48
+ activejob (6.1.5)
49
+ activesupport (= 6.1.5)
50
50
  globalid (>= 0.3.6)
51
- activemodel (6.1.4.1)
52
- activesupport (= 6.1.4.1)
53
- activerecord (6.1.4.1)
54
- activemodel (= 6.1.4.1)
55
- activesupport (= 6.1.4.1)
56
- activestorage (6.1.4.1)
57
- actionpack (= 6.1.4.1)
58
- activejob (= 6.1.4.1)
59
- activerecord (= 6.1.4.1)
60
- activesupport (= 6.1.4.1)
61
- marcel (~> 1.0.0)
51
+ activemodel (6.1.5)
52
+ activesupport (= 6.1.5)
53
+ activerecord (6.1.5)
54
+ activemodel (= 6.1.5)
55
+ activesupport (= 6.1.5)
56
+ activestorage (6.1.5)
57
+ actionpack (= 6.1.5)
58
+ activejob (= 6.1.5)
59
+ activerecord (= 6.1.5)
60
+ activesupport (= 6.1.5)
61
+ marcel (~> 1.0)
62
62
  mini_mime (>= 1.1.0)
63
- activesupport (6.1.4.1)
63
+ activesupport (6.1.5)
64
64
  concurrent-ruby (~> 1.0, >= 1.0.2)
65
65
  i18n (>= 1.6, < 2)
66
66
  minitest (>= 5.1)
@@ -68,15 +68,15 @@ GEM
68
68
  zeitwerk (~> 2.3)
69
69
  ast (2.4.2)
70
70
  builder (3.2.4)
71
- concurrent-ruby (1.1.9)
71
+ concurrent-ruby (1.1.10)
72
72
  crass (1.0.6)
73
- diff-lcs (1.4.4)
73
+ diff-lcs (1.5.0)
74
74
  erubi (1.10.0)
75
- globalid (0.5.2)
75
+ globalid (1.0.0)
76
76
  activesupport (>= 5.0)
77
- i18n (1.8.10)
77
+ i18n (1.10.0)
78
78
  concurrent-ruby (~> 1.0)
79
- loofah (2.12.0)
79
+ loofah (2.16.0)
80
80
  crass (~> 1.0.2)
81
81
  nokogiri (>= 1.5.9)
82
82
  mail (2.7.1)
@@ -84,87 +84,87 @@ GEM
84
84
  marcel (1.0.2)
85
85
  method_source (1.0.0)
86
86
  mini_mime (1.1.2)
87
- minitest (5.14.4)
87
+ minitest (5.15.0)
88
88
  nio4r (2.5.8)
89
- nokogiri (1.12.5-x86_64-linux)
89
+ nokogiri (1.13.3-x86_64-linux)
90
90
  racc (~> 1.4)
91
- parallel (1.21.0)
92
- parser (3.0.2.0)
91
+ parallel (1.22.1)
92
+ parser (3.1.1.0)
93
93
  ast (~> 2.4.1)
94
- racc (1.5.2)
94
+ racc (1.6.0)
95
95
  rack (2.2.3)
96
96
  rack-test (1.1.0)
97
97
  rack (>= 1.0, < 3)
98
- rails (6.1.4.1)
99
- actioncable (= 6.1.4.1)
100
- actionmailbox (= 6.1.4.1)
101
- actionmailer (= 6.1.4.1)
102
- actionpack (= 6.1.4.1)
103
- actiontext (= 6.1.4.1)
104
- actionview (= 6.1.4.1)
105
- activejob (= 6.1.4.1)
106
- activemodel (= 6.1.4.1)
107
- activerecord (= 6.1.4.1)
108
- activestorage (= 6.1.4.1)
109
- activesupport (= 6.1.4.1)
98
+ rails (6.1.5)
99
+ actioncable (= 6.1.5)
100
+ actionmailbox (= 6.1.5)
101
+ actionmailer (= 6.1.5)
102
+ actionpack (= 6.1.5)
103
+ actiontext (= 6.1.5)
104
+ actionview (= 6.1.5)
105
+ activejob (= 6.1.5)
106
+ activemodel (= 6.1.5)
107
+ activerecord (= 6.1.5)
108
+ activestorage (= 6.1.5)
109
+ activesupport (= 6.1.5)
110
110
  bundler (>= 1.15.0)
111
- railties (= 6.1.4.1)
111
+ railties (= 6.1.5)
112
112
  sprockets-rails (>= 2.0.0)
113
113
  rails-dom-testing (2.0.3)
114
114
  activesupport (>= 4.2.0)
115
115
  nokogiri (>= 1.6)
116
116
  rails-html-sanitizer (1.4.2)
117
117
  loofah (~> 2.3)
118
- railties (6.1.4.1)
119
- actionpack (= 6.1.4.1)
120
- activesupport (= 6.1.4.1)
118
+ railties (6.1.5)
119
+ actionpack (= 6.1.5)
120
+ activesupport (= 6.1.5)
121
121
  method_source
122
- rake (>= 0.13)
122
+ rake (>= 12.2)
123
123
  thor (~> 1.0)
124
- rainbow (3.0.0)
124
+ rainbow (3.1.1)
125
125
  rake (13.0.6)
126
- regexp_parser (2.1.1)
126
+ regexp_parser (2.2.1)
127
127
  rexml (3.2.5)
128
- rspec (3.10.0)
129
- rspec-core (~> 3.10.0)
130
- rspec-expectations (~> 3.10.0)
131
- rspec-mocks (~> 3.10.0)
132
- rspec-core (3.10.1)
133
- rspec-support (~> 3.10.0)
134
- rspec-expectations (3.10.1)
128
+ rspec (3.11.0)
129
+ rspec-core (~> 3.11.0)
130
+ rspec-expectations (~> 3.11.0)
131
+ rspec-mocks (~> 3.11.0)
132
+ rspec-core (3.11.0)
133
+ rspec-support (~> 3.11.0)
134
+ rspec-expectations (3.11.0)
135
135
  diff-lcs (>= 1.2.0, < 2.0)
136
- rspec-support (~> 3.10.0)
137
- rspec-mocks (3.10.2)
136
+ rspec-support (~> 3.11.0)
137
+ rspec-mocks (3.11.1)
138
138
  diff-lcs (>= 1.2.0, < 2.0)
139
- rspec-support (~> 3.10.0)
140
- rspec-support (3.10.2)
141
- rubocop (1.22.1)
139
+ rspec-support (~> 3.11.0)
140
+ rspec-support (3.11.0)
141
+ rubocop (1.26.1)
142
142
  parallel (~> 1.10)
143
- parser (>= 3.0.0.0)
143
+ parser (>= 3.1.0.0)
144
144
  rainbow (>= 2.2.2, < 4.0)
145
145
  regexp_parser (>= 1.8, < 3.0)
146
146
  rexml
147
- rubocop-ast (>= 1.12.0, < 2.0)
147
+ rubocop-ast (>= 1.16.0, < 2.0)
148
148
  ruby-progressbar (~> 1.7)
149
149
  unicode-display_width (>= 1.4.0, < 3.0)
150
- rubocop-ast (1.12.0)
151
- parser (>= 3.0.1.1)
150
+ rubocop-ast (1.16.0)
151
+ parser (>= 3.1.1.0)
152
152
  ruby-progressbar (1.11.0)
153
- sprockets (4.0.2)
153
+ sprockets (4.0.3)
154
154
  concurrent-ruby (~> 1.0)
155
155
  rack (> 1, < 3)
156
- sprockets-rails (3.2.2)
157
- actionpack (>= 4.0)
158
- activesupport (>= 4.0)
156
+ sprockets-rails (3.4.2)
157
+ actionpack (>= 5.2)
158
+ activesupport (>= 5.2)
159
159
  sprockets (>= 3.0.0)
160
- thor (1.1.0)
160
+ thor (1.2.1)
161
161
  tzinfo (2.0.4)
162
162
  concurrent-ruby (~> 1.0)
163
163
  unicode-display_width (2.1.0)
164
164
  websocket-driver (0.7.5)
165
165
  websocket-extensions (>= 0.1.0)
166
166
  websocket-extensions (0.1.5)
167
- zeitwerk (2.4.2)
167
+ zeitwerk (2.5.4)
168
168
 
169
169
  PLATFORMS
170
170
  x86_64-linux
@@ -177,7 +177,7 @@ DEPENDENCIES
177
177
  rubocop
178
178
 
179
179
  RUBY VERSION
180
- ruby 3.0.2p107
180
+ ruby 3.1.1p18
181
181
 
182
182
  BUNDLED WITH
183
- 2.2.27
183
+ 2.3.7
@@ -0,0 +1,18 @@
1
+ module PgRls
2
+ module Errors
3
+ class TenantNotFound < StandardError
4
+ def initialize
5
+ reset_tenant_id
6
+ super
7
+ end
8
+
9
+ def message
10
+ "Tenant Doesn't exist"
11
+ end
12
+
13
+ def reset_tenant_id
14
+ PgRls.connection_class.connection.execute('RESET rls.tenant_id')
15
+ end
16
+ end
17
+ end
18
+ end
data/lib/pg_rls/tenant.rb CHANGED
@@ -5,6 +5,7 @@ module PgRls
5
5
  module Tenant
6
6
  class << self
7
7
  def switch(resource)
8
+ @fetch = nil
8
9
  connection_adapter = PgRls.connection_class
9
10
  find_tenant(resource)
10
11
  connection_adapter.connection.execute(format('SET rls.tenant_id = %s',
@@ -18,7 +19,7 @@ module PgRls
18
19
  attr_reader :tenant
19
20
 
20
21
  def fetch
21
- @fetch ||= tenant.find_by_tenant_id(
22
+ @fetch ||= PgRls.main_model.find_by_tenant_id(
22
23
  PgRls.connection_class.connection.execute(
23
24
  "SELECT current_setting('rls.tenant_id')"
24
25
  ).getvalue(0, 0)
@@ -32,9 +33,11 @@ module PgRls
32
33
 
33
34
  PgRls.search_methods.each do |method|
34
35
  @method = method
35
- @tenant ||= PgRls.main_model.send("find_by_#{method}", resource)
36
+ @tenant ||= PgRls.main_model.send("find_by_#{method}!", resource)
36
37
  rescue NoMethodError => e
37
38
  @error = e
39
+ rescue ActiveRecord::RecordNotFound
40
+ raise PgRls::Errors::TenantNotFound
38
41
  end
39
42
  end
40
43
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRls
4
- VERSION = '0.0.1.4.1'
4
+ VERSION = '0.0.1.4.2'
5
5
  end
data/lib/pg_rls.rb CHANGED
@@ -9,6 +9,7 @@ require_relative 'pg_rls/tenant'
9
9
  require_relative 'pg_rls/secure_connection'
10
10
  require_relative 'pg_rls/multi_tenancy'
11
11
  require_relative 'pg_rls/railtie' if defined?(Rails)
12
+ require_relative 'pg_rls/errors/tenant_not_found'
12
13
 
13
14
  # PostgreSQL Row Level Security
14
15
  module PgRls
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_rls
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.4.1
4
+ version: 0.0.1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Laloush
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-16 00:00:00.000000000 Z
11
+ date: 2022-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.2.10
19
+ version: '2.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.2.10
26
+ version: '2.2'
27
27
  description: |2
28
28
  This gem will help you to integrate PostgreSQL RLS to help you develop a great multitenancy application
29
29
  checkout the repository at https://github.com/Dandush03/pg_rls
@@ -63,6 +63,7 @@ files:
63
63
  - lib/pg_rls/Rakefile
64
64
  - lib/pg_rls/database/prepared.rb
65
65
  - lib/pg_rls/database/tasks/admin_database.rake
66
+ - lib/pg_rls/errors/tenant_not_found.rb
66
67
  - lib/pg_rls/multi_tenancy.rb
67
68
  - lib/pg_rls/railtie.rb
68
69
  - lib/pg_rls/schema/down_statements.rb
@@ -82,16 +83,16 @@ require_paths:
82
83
  - lib
83
84
  required_ruby_version: !ruby/object:Gem::Requirement
84
85
  requirements:
85
- - - ">="
86
+ - - "~>"
86
87
  - !ruby/object:Gem::Version
87
- version: 3.0.0
88
+ version: '3.0'
88
89
  required_rubygems_version: !ruby/object:Gem::Requirement
89
90
  requirements:
90
91
  - - ">="
91
92
  - !ruby/object:Gem::Version
92
93
  version: '0'
93
94
  requirements: []
94
- rubygems_version: 3.3.3
95
+ rubygems_version: 3.3.7
95
96
  signing_key:
96
97
  specification_version: 4
97
98
  summary: Write a short summary, because RubyGems requires one.