panda_pal 5.16.3 → 5.16.5
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/config/initializers/apartment.rb +16 -14
- data/lib/panda_pal/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ed57241456e0fe78d006855d50152d47c8a328b777bf77d16b53e0a59519e766
|
|
4
|
+
data.tar.gz: '0748669e4a1e3a83f9e8653b08f8c200b755d9b41a0b61e4dda1b83dbd8859c5'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5bb3ebb3379973fe51332a46807d6e69c55e4134cca476829231dd3539cdfc21e02af95a91dd32300b4bcd54018dd17061f144318b06577d4f33fae44c5a8ee6
|
|
7
|
+
data.tar.gz: 7f924b2f17246b33c5b535c80e0fd6ebef89ccd450d4c78687ae93d2247324ffacb4e8e58c99cfd92f7604ece73e8ebbbd9903af037fa1afa96f8c2063ced03d
|
|
@@ -287,32 +287,34 @@ ActiveSupport.on_load(:action_cable) do
|
|
|
287
287
|
# at which time we hack-in the correct tenant/schema.
|
|
288
288
|
|
|
289
289
|
ActionCable::Server::Worker.set_callback :work, :around do |_, blk|
|
|
290
|
-
# Bit of a hack, but ensures the adapter is initialized (since such may incur DB calls (requiring a connection)
|
|
291
|
-
# which
|
|
292
|
-
|
|
290
|
+
# Bit of a hack, but placing this here ensures the adapter is initialized (since such may incur DB calls (requiring a connection)
|
|
291
|
+
# which could then cause `checkout` to recurse)
|
|
292
|
+
Thread.current[:cable_tenant] = {
|
|
293
|
+
adapter: Apartment::Tenant.adapter,
|
|
294
|
+
tenant: connection.tenant,
|
|
295
|
+
}
|
|
293
296
|
|
|
294
297
|
# If the current thread already has a connection checked out, release it back to the pool so that the later after_checkout
|
|
295
298
|
# callback can set the schema properly.
|
|
296
299
|
pool = Apartment.connection_class.connection_pool
|
|
297
300
|
pool.release_connection if pool.active_connection?
|
|
298
301
|
|
|
299
|
-
|
|
302
|
+
Apartment::Tenant.adapter.instance_variable_set(:@current, connection.tenant)
|
|
303
|
+
|
|
300
304
|
blk.call
|
|
301
305
|
ensure
|
|
302
306
|
Thread.current[:cable_tenant] = nil
|
|
303
307
|
end
|
|
304
308
|
|
|
305
309
|
ActiveSupport.on_load(:active_record) do
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
end
|
|
315
|
-
end
|
|
310
|
+
ActiveRecord::Base.connection.class.set_callback :checkout, :after do |conn|
|
|
311
|
+
next unless (ct = Thread.current[:cable_tenant]).present?
|
|
312
|
+
next unless Apartment::Tenant.adapter.is_a?(Apartment::Adapters::PostgresqlSchemaAdapter)
|
|
313
|
+
next unless conn.pool == Apartment.connection_class.connection_pool
|
|
314
|
+
|
|
315
|
+
adapter = ct[:adapter]
|
|
316
|
+
adapter.instance_variable_set(:@current, ct[:tenant])
|
|
317
|
+
conn.schema_search_path = adapter.send :full_search_path
|
|
316
318
|
end
|
|
317
319
|
end
|
|
318
320
|
end
|
data/lib/panda_pal/version.rb
CHANGED