pg_conn 0.43.0 → 0.44.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 +4 -4
- data/lib/pg_conn/version.rb +1 -1
- data/lib/pg_conn.rb +21 -8
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 51ccb11b750c683d57a02f274b4479366eced6d46c8908fed1e47aca302ff367
|
|
4
|
+
data.tar.gz: ad97bab6ef9fb0e7f821088a58772252ba72c4c9b695703b6ccd3a32fb1f5f80
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 629d0d6afb690bc1ef2f3490d395f81cf5177f86803f5e6049621fec73bcef07ed4b4c644cbf8e834059c7219076f2c62b1ad3b36e7fa1db344a415c9073213c
|
|
7
|
+
data.tar.gz: 50cbacb421a2e4f4332c53737d0b9e8cf88e2b6555fe3c814d728d957f5d1477065f4a5089ff7c11ca77c33634aabf8440bd6aebccee8b92e7c509b7a18ba3ef
|
data/lib/pg_conn/version.rb
CHANGED
data/lib/pg_conn.rb
CHANGED
|
@@ -113,6 +113,10 @@ module PgConn
|
|
|
113
113
|
Literal.new tuples.map { |tuple| "(#{quote_tuple(tuple, **opts)})" }.join(", ")
|
|
114
114
|
end
|
|
115
115
|
|
|
116
|
+
# Quote array elements as a comma separated list of values and enclosed en
|
|
117
|
+
# parenthesis. Eg. [1, 2] => "(1, 2)"
|
|
118
|
+
def self.quote_list(array, **opts) = quote_tuples([array], **opts)
|
|
119
|
+
|
|
116
120
|
# Used to mark strings as literals that should not be quoted. This is the
|
|
117
121
|
# case for row and record values
|
|
118
122
|
class Literal < String; end
|
|
@@ -470,6 +474,9 @@ module PgConn
|
|
|
470
474
|
def quote_tuple(tuple, **opts) = PgConn.quote_tuple(tuple, json_type: self.default_json_type, **opts)
|
|
471
475
|
def quote_tuples(tuples, **opts) = PgConn.quote_tuples(tuples, json_type: self.default_json_type, **opts)
|
|
472
476
|
|
|
477
|
+
# Quote an array as a list. Eg. ["1", 2] => ('1', 2)
|
|
478
|
+
def quote_list(values, **opts) = quote_tuples([values], **opts)
|
|
479
|
+
|
|
473
480
|
# Quote a record and cast it into the given type, the type can also be a
|
|
474
481
|
# table or view. 'data' is an array, hash, or struct representation of the
|
|
475
482
|
# record
|
|
@@ -827,6 +834,7 @@ module PgConn
|
|
|
827
834
|
# :call-seq:
|
|
828
835
|
# insert(table, record|records)
|
|
829
836
|
# insert(table, fields, record|records|tuples|values)
|
|
837
|
+
#
|
|
830
838
|
# insert(schema, table, record|records)
|
|
831
839
|
# insert(schema, table, fields, record|records|tuples|values)
|
|
832
840
|
#
|
|
@@ -834,6 +842,12 @@ module PgConn
|
|
|
834
842
|
#
|
|
835
843
|
# There is no variant that takes a single tuple because it would then be
|
|
836
844
|
# impossible to have array or hash field values
|
|
845
|
+
#
|
|
846
|
+
# TODO
|
|
847
|
+
# insert(table, [fields], field-name-map, object|objects)
|
|
848
|
+
# field-name-map:
|
|
849
|
+
# { database-column-name: object-method-name } # calls method on orbejt
|
|
850
|
+
#
|
|
837
851
|
def insert(*args, upsert: nil, **opts)
|
|
838
852
|
# Normalize arguments
|
|
839
853
|
|
|
@@ -934,16 +948,15 @@ module PgConn
|
|
|
934
948
|
# Execute block with the given set of global or local options and reset
|
|
935
949
|
# them afterwards
|
|
936
950
|
#
|
|
937
|
-
#
|
|
938
|
-
#
|
|
951
|
+
# Global options are :silent, :notice and :warning, they're very useful in
|
|
952
|
+
# RSpec tests
|
|
939
953
|
#
|
|
940
954
|
# Local options are :search_path that runs the block with the given
|
|
941
|
-
# schemas, :username that runs the block as the given user, :
|
|
942
|
-
#
|
|
943
|
-
# transaction
|
|
944
|
-
#
|
|
945
|
-
#
|
|
946
|
-
#
|
|
955
|
+
# schemas, :username that runs the block as the given user, :commit that
|
|
956
|
+
# runs the block in a transaction if true or false; true commits the
|
|
957
|
+
# transaction and false rolls it back (very rarely useful). It is not run
|
|
958
|
+
# in a transaction if :commit is nil. :log controls logging like
|
|
959
|
+
# #logger= but nil (the default) is a nop
|
|
947
960
|
def with(**options, &block)
|
|
948
961
|
search_path = options.delete(:search_path)
|
|
949
962
|
username = options.delete(:username)
|