pg_conn 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/TODO +7 -4
- data/lib/pg_conn/version.rb +1 -1
- data/lib/pg_conn.rb +13 -10
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 206932658b5b0391981261dec373d6366e36f0daf7a617281fc2226d21379ea2
|
4
|
+
data.tar.gz: 7c42613ae06e24f6e596e360ce56bdf9f52515433ee3adf564d68d522439b01d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db655488ffd8772091ea6620b76b95dbffc28efe56c6036b80fbafcbeb3e6db6ff6edc364007954aeb3fa95fbbf32c3fc6edbf2d2f87e574bda5e307d5fe5eaf
|
7
|
+
data.tar.gz: 9a4333e1670a212d5255d01c45a5adb21ef75503a593f6a921345029aef37c52fa620377f492d93cc20f3ee37cf2efbbfaf41f18684e4b384037282963150f01
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-
|
1
|
+
ruby-3.1.2
|
data/TODO
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
TODO
|
2
|
-
o
|
3
|
-
|
4
|
-
|
5
|
-
o
|
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
|
data/lib/pg_conn/version.rb
CHANGED
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
|
-
|
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(
|
225
|
-
end ==
|
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,20 +435,21 @@ 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
|
437
|
-
#
|
438
|
-
# (like #value or #values),
|
439
|
-
# (like #tuple), and an array of
|
440
|
-
# than one record with multiple
|
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
|
-
def call(name, *args, proc: false)
|
445
|
+
def call(name, *args, proc: false) # :proc may interfere with hashes
|
443
446
|
args_sql = args.map { |arg| # TODO: Use pg's encoder
|
444
447
|
case arg
|
445
448
|
when NilClass; "null"
|
446
449
|
when String; "'#{arg}'"
|
447
450
|
when Integer; arg
|
448
451
|
when TrueClass, FalseClass; arg
|
449
|
-
when Array;
|
452
|
+
when Array; "Array['#{arg.join("', '")}']" # Quick and dirty # FIXME
|
450
453
|
when Hash; raise NotImplementedError
|
451
454
|
else
|
452
455
|
raise ArgumentError, "Unrecognized value: #{arg.inspect}"
|
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
|
+
version: 0.5.0
|
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-
|
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
|
@@ -106,8 +106,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
- !ruby/object:Gem::Version
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
|
-
rubygems_version: 3.
|
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: []
|