pg_conn 0.27.1 → 0.28.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: 01735ada71fba436bf8387651722d380b68bfa9c028666946d343e22f94fb1ea
4
- data.tar.gz: de757bfe82276b1641c693f93afcc630bcdea37d1bb33d65888652fdce6f3656
3
+ metadata.gz: 1ecec863d9bc5362325174cc0b8808850857fb6458bf7ebfe935d4c1c7fed8f1
4
+ data.tar.gz: cd377b8f0b6b52dd315643a25e5a965f14f28602ac1e804ec5f14ed65e3dc7fe
5
5
  SHA512:
6
- metadata.gz: d15f076992d6bf1eaa05b5ba8b7f3a3cc7ca4150543449717ecf1a94f16d08d71602e55384dedb13fba4ab06465a8dc1ae1e109ef698cf848d0264243d49e1c5
7
- data.tar.gz: 69b9a3cbd175d20e4b806a18124a008eff5ef33bdcfd4d3b482d50cbba20ce95f9684a407b1122cd7dee2464b96496b2803d22c93b2c6190ba52332248a8de4d
6
+ metadata.gz: f8c2acce15051e71533db05379da6939882e5e077f1c002cdce9f904bc026b5c09b317d5a948ca0341ed7af1b6ef4a5a974c3dfed3edd96333aa90bc169c97d7
7
+ data.tar.gz: 827c0194d8a9897ccc27b5acb7b8c2210a0a7ca611648b9acb0852f09afd3c7378e014552256fede9e8da635f22fd475d923eb67b06231adaaf01bc5f6d5d366
@@ -1,3 +1,3 @@
1
1
  module PgConn
2
- VERSION = "0.27.1"
2
+ VERSION = "0.28.0"
3
3
  end
data/lib/pg_conn.rb CHANGED
@@ -31,6 +31,10 @@ module PgConn
31
31
  end
32
32
  end
33
33
 
34
+ # Used to mark strings as literals that should not be quoted. This is the
35
+ # case for row and record values
36
+ class Literal < String; end
37
+
34
38
  # All results from the database are converted into native Ruby types
35
39
  class Connection
36
40
  # Make PgConn::Connection pretend to be an instance of the PgConn module
@@ -246,6 +250,8 @@ module PgConn
246
250
  end
247
251
  end
248
252
 
253
+ def literal(arg) Literal.new(arg) end
254
+
249
255
  # Quote argument as an identifier. The argument should be a non-nil string
250
256
  # or a symbol
251
257
  def quote_identifier(s)
@@ -274,6 +280,7 @@ module PgConn
274
280
  #
275
281
  def quote_value(value, elem_type: nil)
276
282
  case value
283
+ when Literal; value
277
284
  when String; @pg_connection.escape_literal(value)
278
285
  when Integer, Float; value.to_s
279
286
  when true, false; value.to_s
@@ -363,6 +370,13 @@ module PgConn
363
370
  value("select count(*) from (#{inner_query}) as inner_query")
364
371
  end
365
372
 
373
+ # TODO (but breaks a lot of code)
374
+ # value 1
375
+ # value? 0 or 1
376
+ #
377
+ # values 1 or more
378
+ # values? 0 or more
379
+
366
380
  # Return a single value. It is an error if the query doesn't return a
367
381
  # single record with a single column.
368
382
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_conn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.27.1
4
+ version: 0.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-23 00:00:00.000000000 Z
11
+ date: 2024-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg