pg_conn 0.28.0 → 0.29.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: 1ecec863d9bc5362325174cc0b8808850857fb6458bf7ebfe935d4c1c7fed8f1
4
- data.tar.gz: cd377b8f0b6b52dd315643a25e5a965f14f28602ac1e804ec5f14ed65e3dc7fe
3
+ metadata.gz: ba42158e0277b532ebcdb7125dd0c963de3c936a4bdb918e1a980fd6aa2674ed
4
+ data.tar.gz: c371efcf188d9c49b7e005e2cb4f92f72431b6b20e0fbd4766904d8b99743ed4
5
5
  SHA512:
6
- metadata.gz: f8c2acce15051e71533db05379da6939882e5e077f1c002cdce9f904bc026b5c09b317d5a948ca0341ed7af1b6ef4a5a974c3dfed3edd96333aa90bc169c97d7
7
- data.tar.gz: 827c0194d8a9897ccc27b5acb7b8c2210a0a7ca611648b9acb0852f09afd3c7378e014552256fede9e8da635f22fd475d923eb67b06231adaaf01bc5f6d5d366
6
+ metadata.gz: 9d518daefe587aca974092084628505c9c82a8615e4cda9baf3ea3b3526ebdf2e48be1adc0bfe4231f4b617353359c0942f16f6d97c33bc67cc744db0dd7d11f
7
+ data.tar.gz: b534cc5f4669c84e6248f57aa6abef4678d37405b6008814f74521d9c691cc0cd4b4983795429832f40c9618071248887ba5b3bcb09c2fd05ca21f37126ae696
data/TODO CHANGED
@@ -1,9 +1,12 @@
1
1
  TODO
2
- o Add a <fetch>! method
3
- value? 0 or 1
4
- value 1
5
- values 0 or n
6
- values! 1 or more
2
+ o Add support for hstore (a hash)
3
+
4
+ o Add a <fetch>! method. Require v2
5
+ value? 0 or 1
6
+ value 1
7
+ values 0 or n
8
+ values? 0 or n
9
+ values! 1 or more
7
10
 
8
11
  o Instrumentation of connection object
9
12
 
@@ -1,3 +1,3 @@
1
1
  module PgConn
2
- VERSION = "0.28.0"
2
+ VERSION = "0.29.0"
3
3
  end
data/lib/pg_conn.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "pg"
2
2
  require 'ostruct'
3
+ require 'json'
3
4
 
4
5
  require_relative "pg_conn/version"
5
6
  require_relative "pg_conn/role_methods"
@@ -269,6 +270,10 @@ module PgConn
269
270
  # true/false, Time/Date/DateTime, and arrays. Other types may require
270
271
  # special handling
271
272
  #
273
+ # Hashes are quoted as a literal JSON expression. The result is a string
274
+ # and it is the application's responsibility to cast them to either 'json'
275
+ # or 'jsonb'
276
+ #
272
277
  # Note that a tuple value (an array) must be quoted using #quote_tuple
273
278
  # because #quote_value would quote the tuple as an array instead of a list
274
279
  # of values
@@ -294,6 +299,7 @@ module PgConn
294
299
  else
295
300
  "array[#{value.map { |elem| quote_value(elem) }.join(', ')}]"
296
301
  end
302
+ when Hash; value.to_json
297
303
  else
298
304
  @pg_connection.escape_literal(value.to_s)
299
305
  end
@@ -346,6 +352,8 @@ module PgConn
346
352
  #
347
353
  # Return true iff the query returns exactly one record. Use '!empty?' to
348
354
  # check if the query returns one or more records
355
+ #
356
+ # TODO: Rename #present? and use #exists? to query schema objects
349
357
  def exist?(*query)
350
358
  !empty?(*query)
351
359
  end
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.28.0
4
+ version: 0.29.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-30 00:00:00.000000000 Z
11
+ date: 2025-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg