multitenancy_tools 0.1.8 → 0.1.9

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
  SHA1:
3
- metadata.gz: b17c6615883612747959c317412a274e079dc2c7
4
- data.tar.gz: 9159b347030e2aea1985ffa2cea028b4d489d89f
3
+ metadata.gz: 660954dd5f64df45380a4cc405912a4dbb8366ec
4
+ data.tar.gz: c46e9cc25a12190d1648262e0cc57874dfc9914e
5
5
  SHA512:
6
- metadata.gz: 3eec95eda8db2c65de64ed630dd17b05c3a53b7b249bcaf2e4693f470a616ea2e25ef442e6daaac4038d61a231fb45f15ecd658fd0ba034845a2eb558c7c65f9
7
- data.tar.gz: aafbd8959cac1ca983bb5800788453bdcfb45120e89b40f78f73b83206bb8a445f614e57cc4c79b76ce8266ee7a76180c2df41cc83338f754a906ace0f4c7325
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
- @connection.schema_search_path = @schema
16
+ set_path_if_required(@schema)
17
17
  yield
18
18
  ensure
19
- @connection.schema_search_path = original_path
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
@@ -1,3 +1,3 @@
1
1
  module MultitenancyTools
2
- VERSION = '0.1.8'
2
+ VERSION = '0.1.9'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multitenancy_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lenon Marcel