pg_conn 0.38.0 → 0.38.2
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/lib/pg_conn/schema_methods.rb +1 -1
- data/lib/pg_conn/session_methods.rb +3 -0
- data/lib/pg_conn/version.rb +1 -1
- data/lib/pg_conn.rb +10 -4
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27da5832145c359fa1472604184f836add4fabceb458dee4b609c05b6eec5196
|
4
|
+
data.tar.gz: 109029c0961d83cb35710d2f716a31412eb1fcf68d55b05b1d1d6dc26af6b8d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f787e6859f348afd97657c15f6fce1c75ab8e1dc0eeb04ef703879b6b50c493246eb71ec1690b8eb3f2c3f98fefd0b204d7ddde5e6e5d9fe76de5f46c21ff964
|
7
|
+
data.tar.gz: 15968312f5b7f5b0835ebd694484deb6ac84c4dd51c57b99d710b72b08d51d154c040f61acef2751037a7f1d0967f3d7ccdcf271d29ce5cbd4432055e61dc003
|
@@ -152,7 +152,7 @@ module PgConn
|
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
155
|
-
# Set
|
155
|
+
# Set current serial value for the table
|
156
156
|
def set_serial(schema, table, value)
|
157
157
|
uid = "#{schema}.#{table}"
|
158
158
|
seq = sequence(schema, table) or raise ArgumentError, "Table #{uid} does not have a sequence"
|
@@ -84,6 +84,9 @@ module PgConn
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
+
# The following functions enable or disable triggers in per-user sessions
|
88
|
+
# instead of globally as "alter table" does
|
89
|
+
|
87
90
|
# Return true if session triggers are enabled. Triggers are enabled by
|
88
91
|
# default by Postgres
|
89
92
|
def triggers?() conn.value "select current_setting('session_replication_role') <> 'replica'" end
|
data/lib/pg_conn/version.rb
CHANGED
data/lib/pg_conn.rb
CHANGED
@@ -664,9 +664,11 @@ module PgConn
|
|
664
664
|
|
665
665
|
# TODO: #group - same as table but partitions a table on the given keys
|
666
666
|
# returning a map from key to array of records
|
667
|
-
|
667
|
+
#
|
668
668
|
# TODO: An #array method that returns a map from id to tuple. Hmm... almost
|
669
669
|
# the same as #map
|
670
|
+
#
|
671
|
+
# TODO: Swap key and query arguments
|
670
672
|
|
671
673
|
# Return a hash from the record id column to an OpenStruct representation
|
672
674
|
# of the record. If the :key_column option is defined it will be used
|
@@ -718,6 +720,7 @@ module PgConn
|
|
718
720
|
# group-by on the key and array_agg on the remaining values. The value is
|
719
721
|
# an array of tuples if the query has more than one value field and an
|
720
722
|
# array of values if there is only one value field
|
723
|
+
#
|
721
724
|
def multimap(query, key = nil, symbol: false)
|
722
725
|
r = pg_exec(query)
|
723
726
|
begin
|
@@ -821,7 +824,7 @@ module PgConn
|
|
821
824
|
raise ArgumentError
|
822
825
|
end
|
823
826
|
elsif data.is_a?(Hash)
|
824
|
-
method = :value # The pg_conn method when only one record is inserted
|
827
|
+
method = upsert ? :value? : :value # The pg_conn method when only one record is inserted
|
825
828
|
fields ||= data.keys
|
826
829
|
tuples = [fields.map { |field| data[field] }]
|
827
830
|
else
|
@@ -847,7 +850,7 @@ module PgConn
|
|
847
850
|
)
|
848
851
|
end
|
849
852
|
|
850
|
-
# Use upsert. Currently
|
853
|
+
# Use upsert. Currently only 'on conflict do nothing' is supported
|
851
854
|
def upsert(*args)
|
852
855
|
insert(*args, upsert: true)
|
853
856
|
end
|
@@ -913,6 +916,7 @@ module PgConn
|
|
913
916
|
#
|
914
917
|
# TODO: Make sure the transaction stack is emptied on postgres errors
|
915
918
|
def exec(sql, commit: true, fail: true, silent: self.silent)
|
919
|
+
return nil if sql.nil? || Array[sql].empty?
|
916
920
|
transaction(commit: commit) {
|
917
921
|
begin
|
918
922
|
execute(sql, fail: fail, silent: silent)
|
@@ -928,6 +932,7 @@ module PgConn
|
|
928
932
|
# #execute? method because any failure rolls back the whole transaction
|
929
933
|
# stack. TODO: Check which exceptions that should be captured
|
930
934
|
def exec?(sql, commit: true, silent: true)
|
935
|
+
return nil if sql.nil? || Array[sql].empty?
|
931
936
|
begin
|
932
937
|
exec(sql, commit: commit, fail: true, silent: silent)
|
933
938
|
rescue PG::Error
|
@@ -945,6 +950,7 @@ module PgConn
|
|
945
950
|
#
|
946
951
|
# TODO: Handle postgres exceptions wrt transaction state and stack
|
947
952
|
def execute(sql, fail: true, silent: self.silent)
|
953
|
+
return nil if sql.nil? || Array[sql].empty?
|
948
954
|
if @pg_connection
|
949
955
|
begin
|
950
956
|
pg_exec(sql, silent: silent)&.cmd_tuples
|
@@ -1320,7 +1326,7 @@ module PgConn
|
|
1320
1326
|
#
|
1321
1327
|
# Execute statement(s) on the server. If the argument is an array of
|
1322
1328
|
# commands, the commands are concatenated with ';' before being sent to the
|
1323
|
-
# server. #pg_exec returns a PG::Result object or nil if +arg+ was empty
|
1329
|
+
# server. #pg_exec returns a PG::Result object or nil if +arg+ was nil or empty
|
1324
1330
|
#
|
1325
1331
|
# Postgres errors are passed through and #error and #err set to the last
|
1326
1332
|
# statement's SQL errors or nil if it succeeded
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_conn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.38.
|
4
|
+
version: 0.38.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claus Rasmussen
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: pg
|
@@ -92,7 +91,6 @@ homepage: http://www.nowhere.com/
|
|
92
91
|
licenses: []
|
93
92
|
metadata:
|
94
93
|
homepage_uri: http://www.nowhere.com/
|
95
|
-
post_install_message:
|
96
94
|
rdoc_options: []
|
97
95
|
require_paths:
|
98
96
|
- lib
|
@@ -107,8 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
105
|
- !ruby/object:Gem::Version
|
108
106
|
version: '0'
|
109
107
|
requirements: []
|
110
|
-
rubygems_version: 3.
|
111
|
-
signing_key:
|
108
|
+
rubygems_version: 3.6.9
|
112
109
|
specification_version: 4
|
113
110
|
summary: Gem pg_conn
|
114
111
|
test_files: []
|