pg_conn 0.4.3 → 0.5.1

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: 308fc149f0ee84be457ed10f26c2fcb7a8b5ddd21678301820173b067f6a5725
4
- data.tar.gz: ea285e08ddc1a5728f7ae022ccd85df8e6312f15f8b8cf7cbdfbf61e1b584a9c
3
+ metadata.gz: 4831e76784a204c8466e0a58211c24f011e372eea4138b745e236b6f12806646
4
+ data.tar.gz: 63a20d32f5882ff6e1961281c655b7c98ac0265910db657f7aef9f433271ddba
5
5
  SHA512:
6
- metadata.gz: 8140b39f3c6930592312b6ac97f9c2a64eead993c37cf6b85caaaa83bcacc723a2a8b14381fcb422d34013290e905d1740b8a9974823fb25e6e3f7debb0c6d27
7
- data.tar.gz: 52209c53fd85e21fa6baf2e966d39f75459974c0fd0d8a2086923944f7ad750e0c599d71764add2eb7c88b4ea471a5ee4ce194def68b1586a9e5e49b1a0b0f01
6
+ metadata.gz: b9791b2c5b23ee1c49cb1447309545ea091acc8ac35111f9c856594f9af210a4bf68f7d2dcf49b9e6fb3cab76c259f1d4bb2056e6655c5ac5a02eb943efebf28
7
+ data.tar.gz: 173ade9118cd45141c632a4955c7a97f192d93a719ddaad4a7378408ce2dd01d531fe750896368c8399780327ade3362bff4539b08b1fd6c4a13da1a4d472528
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.7.1
1
+ ruby-3.1.2
data/TODO CHANGED
@@ -1,11 +1,14 @@
1
1
  TODO
2
- o Option to accept no records when using #value, #tuple, and #struct. The
3
- alternative is to use the 'one-table' as base table in the query and then
4
- left join the rest
5
- o Implement search_path
2
+ o Use SQL parameters. Optionally with a different syntax:
3
+ $var - Value that gets single-quoted
4
+ @var - Identifier that gets double-quoted (@ for "attribute")
5
+ o Option to accept no records when using #value, #tuple, and #struct. Maybe
6
+ value?, tuple?, struct?. The alternative is to use the 'one-table' as base
7
+ table in the query and then left join the rest
6
8
  o Proper implementation of call of functions and procedures: Functions should
7
9
  be called through #value, #tuple etc. and procedures through #call.
8
10
  Proceduer output parameters needs handling too
11
+ o Implement search_path
9
12
  o Create an abstract PgConnBase and have PgStmts (writes statements to array)
10
13
  and PgConn (sends statements to server) classes derived from it
11
14
  o fix silent
@@ -1,3 +1,3 @@
1
1
  module PgConn
2
- VERSION = "0.4.3"
2
+ VERSION = "0.5.1"
3
3
  end
data/lib/pg_conn.rb CHANGED
@@ -219,10 +219,12 @@ module PgConn
219
219
  # Return true if the table or the result of the query is empty
220
220
  def empty?(arg, where_clause = nil)
221
221
  if arg =~ /\s/
222
- count("select 1 from (#{arg}) as inner_query")
222
+ value "select count(*) from (#{arg} limit 1) as inner_query"
223
+ elsif where_clause
224
+ value "select count(*) from (select 1 from #{arg} where #{where_clause} limit 1) as inner_query"
223
225
  else
224
- count("select 1 from #{arg}" + (where_clause ? " where #{where_clause}" : ""))
225
- end == 1
226
+ value "select count(*) from (select 1 from #{arg} limit 1) as inner_query"
227
+ end == 0
226
228
  end
227
229
 
228
230
  # :call-seq:
@@ -433,11 +435,12 @@ module PgConn
433
435
  end
434
436
 
435
437
  # Return the value of calling the given function (which can be a String or
436
- # a Symbol). It dynamically detects the structure of the result and return
437
- # a value or an array of values if the result contained only one column
438
- # (like #value or #values), a tuple if the record has multiple columns
439
- # (like #tuple), and an array of of tuples if the result contained more
440
- # than one record with multiple columns (like #tuples)
438
+ # a Symbol and can contain the schema of the function). It dynamically
439
+ # detects the structure of the result and return a value or an array of
440
+ # values if the result contained only one column (like #value or #values),
441
+ # a tuple if the record has multiple columns (like #tuple), and an array of
442
+ # of tuples if the result contained more than one record with multiple
443
+ # columns (like #tuples)
441
444
  #
442
445
  def call(name, *args, proc: false) # :proc may interfere with hashes
443
446
  args_sql = args.map { |arg| # TODO: Use pg's encoder
data/pg_conn.gemspec CHANGED
@@ -11,7 +11,6 @@ Gem::Specification.new do |spec|
11
11
  spec.summary = "Gem pg_conn"
12
12
  spec.description = "Gem pg_conn"
13
13
  spec.homepage = "http://www.nowhere.com/"
14
- spec.required_ruby_version = ">= 2.4.0"
15
14
 
16
15
  spec.metadata["homepage_uri"] = spec.homepage
17
16
 
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.4.3
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-01 00:00:00.000000000 Z
11
+ date: 2022-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -91,7 +91,7 @@ homepage: http://www.nowhere.com/
91
91
  licenses: []
92
92
  metadata:
93
93
  homepage_uri: http://www.nowhere.com/
94
- post_install_message:
94
+ post_install_message:
95
95
  rdoc_options: []
96
96
  require_paths:
97
97
  - lib
@@ -99,15 +99,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - ">="
101
101
  - !ruby/object:Gem::Version
102
- version: 2.4.0
102
+ version: '0'
103
103
  required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  requirements:
105
105
  - - ">="
106
106
  - !ruby/object:Gem::Version
107
107
  version: '0'
108
108
  requirements: []
109
- rubygems_version: 3.1.2
110
- signing_key:
109
+ rubygems_version: 3.3.18
110
+ signing_key:
111
111
  specification_version: 4
112
112
  summary: Gem pg_conn
113
113
  test_files: []