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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9b707fbab740595f05ebe65cbd36f20e996875f568b1c26ad37b60cfb42cb65
4
- data.tar.gz: e5984072e4e09eb9f7ac76915f00d29d08e1766e1ad8edef9b90d56fd61a7313
3
+ metadata.gz: 51ccb11b750c683d57a02f274b4479366eced6d46c8908fed1e47aca302ff367
4
+ data.tar.gz: ad97bab6ef9fb0e7f821088a58772252ba72c4c9b695703b6ccd3a32fb1f5f80
5
5
  SHA512:
6
- metadata.gz: ed0c6002be578ca08f8a002b438c34eada70090bf362ea5fb9d642559101fc53827b42b2cf962e60803c02c011df5b6eef92bf5de5045faa18b47affc9a7a71c
7
- data.tar.gz: d75913f57aac31fcb60c91f06958a746b20cd4559bd0feda169f12c48c173aa721423bacdfb883ed5612106f4e1320add1913d39e72d943abde483adb25a30df
6
+ metadata.gz: 629d0d6afb690bc1ef2f3490d395f81cf5177f86803f5e6049621fec73bcef07ed4b4c644cbf8e834059c7219076f2c62b1ad3b36e7fa1db344a415c9073213c
7
+ data.tar.gz: 50cbacb421a2e4f4332c53737d0b9e8cf88e2b6555fe3c814d728d957f5d1477065f4a5089ff7c11ca77c33634aabf8440bd6aebccee8b92e7c509b7a18ba3ef
@@ -1,3 +1,3 @@
1
1
  module PgConn
2
- VERSION = "0.43.0"
2
+ VERSION = "0.44.0"
3
3
  end
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
- # The global options :silent, :notice and :warning are supported, they're
938
- # very useful in RSpec tests
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, :log that
942
- # controls logging (see #logger=), :commit that runs the block in a
943
- # transaction if true or false; true commits the transaction and false
944
- # rolls it back (very rarely useful). It is not run in a transaction if
945
- # :commit is nil
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_conn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.43.0
4
+ version: 0.44.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen