sequel-search-path 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sequel/extensions/search_path/version.rb +1 -1
- data/lib/sequel/extensions/search_path.rb +7 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18c02e68988e33295e7308820956a65f40c666e4
|
4
|
+
data.tar.gz: a8aa4a36a988a10c7cc114508afb40c8625cdd42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ee5a79fc0ccecf3e14d3bbc7e366c0d483a14ba10143228170b1f357a7530cf172eee38c5b020440f40550ed2ca4c09c2fcb7f8e0161a1b4d428a01b9b84a34
|
7
|
+
data.tar.gz: afb99f180818c414602b74e004a72fbf6a13a0dca4de784f01f70af2a8ea686fb7bb356bab49d0723844c67e7de8c78d1e7788198da155b81f7d960a7aa3abbe
|
@@ -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
|
-
|
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.
|
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-
|
11
|
+
date: 2016-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|