panda_pal 5.16.3 → 5.16.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/config/initializers/apartment.rb +14 -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: 31f691e98fe16d192785ff162ece3e7b7dc4964a89db280769d3f1197a1ba94e
|
4
|
+
data.tar.gz: 67262506ba9efad1143e38570d56418d2ac3a5c44d6daa3f0ea8ecd0cc54ce3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 119ab51e712dd115adaa63f6ffe19985d74f73bfa2c4a3e0663fec31689839e35db2c4a0995ce68581077d251b94082e2e182fb62aa94129dac41ca7981b07c3
|
7
|
+
data.tar.gz: cb0cd5101c6a1123b027ee494d9a2044d54c3280baba134d5066cd5dfcb1309dafa4b25c0a3f69215274b0350e309e7e1fc6c1aa81248b4c844c5a29eb1142ff
|
@@ -287,32 +287,32 @@ 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
|
-
Thread.current[:cable_tenant] = connection.tenant
|
300
302
|
blk.call
|
301
303
|
ensure
|
302
304
|
Thread.current[:cable_tenant] = nil
|
303
305
|
end
|
304
306
|
|
305
307
|
ActiveSupport.on_load(:active_record) do
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
end
|
315
|
-
end
|
308
|
+
ActiveRecord::Base.connection.class.set_callback :checkout, :after do |conn|
|
309
|
+
next unless (ct = Thread.current[:cable_tenant]).present?
|
310
|
+
next unless Apartment::Tenant.adapter.is_a?(Apartment::Adapters::PostgresqlSchemaAdapter)
|
311
|
+
next unless conn.pool == Apartment.connection_class.connection_pool
|
312
|
+
|
313
|
+
adapter = ct[:adapter]
|
314
|
+
adapter.instance_variable_set(:@current, ct[:tenant])
|
315
|
+
conn.schema_search_path = adapter.send :full_search_path
|
316
316
|
end
|
317
317
|
end
|
318
318
|
end
|
data/lib/panda_pal/version.rb
CHANGED