pg_rls 0.1.4 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1bead0b6e11e78f3aebe2c843c8cceaa178664bad5755f4f6858893f0232979c
4
- data.tar.gz: c91f321f93c5d79aebccf09413f98580cc64104a32e350f874dce1c170c1c6a8
3
+ metadata.gz: d38cc4bc08fa20b5aa5e9162f36dfbdb6d8bfad6d7a368eb07af55da3c916c91
4
+ data.tar.gz: 7f2f2fe18ab7b2deb4322fa962afd73a1a166f5508378f18c7cd432f0a7692e3
5
5
  SHA512:
6
- metadata.gz: 3baca7c6f170a2ffe07538413374230163d6a907372186bfe3bbab61b5fe8f7eb32402bd4781ef6f0a35b0f8f80e6b6dd2df1115f807810955a606b899f13eb9
7
- data.tar.gz: '00866118e32d11bacc622119a0bbd02880c1f231b59fed3f65b58b176b29b96f0a38469b4071ebc3f4d32c3261a5090153683bc48512a556f48f4edbf72d09b3'
6
+ metadata.gz: 62f98f818a074ec8fcefae101469a6ec62a8ef0a7a38a35ef82bf8215df33d65e4a4692855b97434672570193da84fdb27e5899d78fd39bc60b0757339b8fa56
7
+ data.tar.gz: 82b7ce76f7966a2e7ba6206d1b780b660f39853495947abb83780d7fc4a026adfaf156378e5973383c4fc893d25a96e7ededbf41139f71b9a2712312136c8fa7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pg_rls (0.1.4)
4
+ pg_rls (0.1.6)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -131,6 +131,8 @@ GEM
131
131
  net-smtp (0.4.0)
132
132
  net-protocol
133
133
  nio4r (2.5.9)
134
+ nokogiri (1.15.4-arm64-darwin)
135
+ racc (~> 1.4)
134
136
  nokogiri (1.15.4-x86_64-linux)
135
137
  racc (~> 1.4)
136
138
  parallel (1.23.0)
@@ -265,6 +267,7 @@ GEM
265
267
  zeitwerk (2.6.12)
266
268
 
267
269
  PLATFORMS
270
+ arm64-darwin-22
268
271
  x86_64-linux
269
272
 
270
273
  DEPENDENCIES
@@ -22,14 +22,13 @@ end
22
22
  namespace :db do
23
23
  include PgRls::Schema::UpStatements
24
24
 
25
- override_task grant_usage: :load_config do
25
+ override_task :load_config do
26
26
  PgRls.instance_variable_set(:@as_db_admin, true)
27
- create_rls_user
27
+ Rake::Task['db:load_config:original'].invoke
28
28
  end
29
29
 
30
- override_task abort_if_pending_migrations: :load_config do
31
- PgRls.instance_variable_set(:@as_db_admin, true)
32
- Rake::Task['db:abort_if_pending_migrations:original'].invoke
30
+ override_task grant_usage: :load_config do
31
+ create_rls_user
33
32
  end
34
33
 
35
34
  namespace :test do
@@ -12,12 +12,9 @@ module PgRls
12
12
  end
13
13
 
14
14
  def load_tenant_attribute!(msg)
15
- if PgRls.admin_connection?
16
- msg['admin'] = true
17
- else
18
- tenant = PgRls::Tenant.fetch!
19
- msg['pg_rls'] = tenant.id
20
- end
15
+ return msg['admin'] = true if PgRls.admin_connection?
16
+
17
+ msg['pg_rls'] ||= PgRls::Tenant.fetch&.id
21
18
  end
22
19
  end
23
20
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRls
4
- VERSION = '0.1.4'
4
+ VERSION = '0.1.6'
5
5
  end
data/lib/pg_rls.rb CHANGED
@@ -50,7 +50,9 @@ module PgRls
50
50
  def establish_new_connection!(admin: false)
51
51
  self.as_db_admin = admin
52
52
 
53
+ db_config = PgRls.main_model.connection_db_config.configuration_hash
53
54
  execute_rls_in_shards do |connection_class, pool|
55
+ connection_class.connection_pool.disconnect!
54
56
  connection_class.remove_connection
55
57
  connection_class.establish_connection(pool.db_config)
56
58
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_rls
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Laloush
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-13 00:00:00.000000000 Z
11
+ date: 2024-04-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  This gem will help you to integrate PostgreSQL RLS to help you develop a great multitenancy application
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  - !ruby/object:Gem::Version
87
87
  version: '0'
88
88
  requirements: []
89
- rubygems_version: 3.4.22
89
+ rubygems_version: 3.5.7
90
90
  signing_key:
91
91
  specification_version: 4
92
92
  summary: Write a short summary, because RubyGems requires one.