sequel-search-path 0.1.0 → 0.2.0

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: 085c3c7649911aa5244ccd0600b6e0a66cc4e992
4
- data.tar.gz: 7f90504ae2b1660dabab063e35d78e44c8662e40
3
+ metadata.gz: 18c02e68988e33295e7308820956a65f40c666e4
4
+ data.tar.gz: a8aa4a36a988a10c7cc114508afb40c8625cdd42
5
5
  SHA512:
6
- metadata.gz: ea1cfbbb79cf053cf739640e2c0fa3b9a96950045acd8e2743712a50e66b859031e6aef8611bc2db4ac245724eb8404e9123c425344caed590a8f15a83ea9aa5
7
- data.tar.gz: 721703c73bf2560fa49fdc4e4cd30801cd8cfdf4e5a72a11c3200fa1fe0b6cd8f524599be20c5ec20e7d00d24d5d3648253d7e01d1cf567b00263d41c1b5bc8e
6
+ metadata.gz: 0ee5a79fc0ccecf3e14d3bbc7e366c0d483a14ba10143228170b1f357a7530cf172eee38c5b020440f40550ed2ca4c09c2fcb7f8e0161a1b4d428a01b9b84a34
7
+ data.tar.gz: afb99f180818c414602b74e004a72fbf6a13a0dca4de784f01f70af2a8ea686fb7bb356bab49d0723844c67e7de8c78d1e7788198da155b81f7d960a7aa3abbe
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sequel
4
4
  module SearchPath
5
- VERSION = '0.1.0'
5
+ VERSION = '0.2.0'
6
6
  end
7
7
  end
@@ -28,7 +28,13 @@ module Sequel
28
28
  def schemas=(schemas)
29
29
  schemas = schemas.map(&:to_sym).uniq
30
30
  Thread.current[schemas_key] = schemas
31
- set_search_path(schemas)
31
+
32
+ # Set the search_path in Postgres, unless it's in transaction rollback.
33
+ # If it is, the search_path will be reset for us anyway, and the SQL
34
+ # call will just raise another error.
35
+ unless synchronize(&:transaction_status) == PG::PQTRANS_INERROR
36
+ set_search_path(schemas)
37
+ end
32
38
  end
33
39
 
34
40
  # The schema that new objects will be created in.
@@ -47,16 +53,6 @@ module Sequel
47
53
  placeholders = schemas.map{'?'}.join(', ')
48
54
  placeholders = "''" if placeholders.empty?
49
55
  self["SET search_path TO #{placeholders}", *schemas].get
50
- rescue Sequel::DatabaseError => e
51
- if e.wrapped_exception.is_a?(PG::InFailedSqlTransaction)
52
- # This command will fail if we're in a transaction that the DB is
53
- # rolling back due to an error, but in that case, there's no need to run
54
- # it anyway (Postgres will reset the search_path for us). Since there's
55
- # no way to know whether it will fail until we try it, and there's
56
- # nothing to be done with the error it throws, just ignore it.
57
- else
58
- raise
59
- end
60
56
  end
61
57
 
62
58
  def schemas_key
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel-search-path
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Hanks
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-18 00:00:00.000000000 Z
11
+ date: 2016-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler