multitenancy_tools 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/multitenancy_tools/schema_switcher.rb +12 -2
- data/lib/multitenancy_tools/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 660954dd5f64df45380a4cc405912a4dbb8366ec
|
4
|
+
data.tar.gz: c46e9cc25a12190d1648262e0cc57874dfc9914e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 291d66ebc172a1b205c684f46bed7bc228e9b05a99d456906685bd1dc85db169a898bede1c72bfae54e350a10caa9390f7c7a15c4de62f4c76297730da27fe96
|
7
|
+
data.tar.gz: cc438125123d4bc2ffa963be2445fa86973d36f7029562caf604b51767d038ba371de825648d5c1411d66d53be93d74eebfac96cef7e9dc17814ad42048aad25
|
@@ -13,10 +13,20 @@ module MultitenancyTools
|
|
13
13
|
# yields the block and then change search_path back to its previous value.
|
14
14
|
def run(&block)
|
15
15
|
original_path = @connection.schema_search_path
|
16
|
-
@
|
16
|
+
set_path_if_required(@schema)
|
17
17
|
yield
|
18
18
|
ensure
|
19
|
-
|
19
|
+
set_path_if_required(original_path)
|
20
|
+
end
|
21
|
+
|
22
|
+
protected
|
23
|
+
|
24
|
+
# Change search_path only if the current search_path is different. This
|
25
|
+
# avoids unnecessary queries to change the connection search_path when it
|
26
|
+
# already has the desired value.
|
27
|
+
def set_path_if_required(schema)
|
28
|
+
return if @connection.schema_search_path == schema
|
29
|
+
@connection.schema_search_path = schema
|
20
30
|
end
|
21
31
|
end
|
22
32
|
end
|