pg_conn 0.5.1 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/TODO +31 -0
- data/lib/pg_conn/rdbms_methods.rb +2 -2
- data/lib/pg_conn/version.rb +1 -1
- data/lib/pg_conn.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ecdb9e5679acd6da6db9b98fc179941b5752727f7ec064bbb3168ed3ca33d33
|
4
|
+
data.tar.gz: 28152343bf4490ad17f770799e4fa211662cab13cc19c639049d465a4c610f2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68767284661c94cc8c0a5e610d967bfe8e31db67cf3a6998b68895ba1f0ca30e003e68036ac6e23788e0175226cb77a06c1ea883362dfb5386874aeeed21928c
|
7
|
+
data.tar.gz: 251335c7c53cfd1cfac031576bb854aada2e034e64587a58932eb63cce35f48e9867579c52bcc48d91368e93d6d7beaddc1c5334c2207d063684cdbea4335ec4
|
data/TODO
CHANGED
@@ -1,4 +1,35 @@
|
|
1
1
|
TODO
|
2
|
+
o #group method
|
3
|
+
|
4
|
+
group(query, column: nil)
|
5
|
+
group(query) { |record| group_expression }
|
6
|
+
|
7
|
+
# TODO: Move to ext/pg_conn or include in pg_conn
|
8
|
+
module PgConn
|
9
|
+
class Connection
|
10
|
+
def group(query, column: nil) # FIXME: default nil -> the first field
|
11
|
+
r = pg_exec(query)
|
12
|
+
begin
|
13
|
+
column = (column || r.fname(0)).to_s
|
14
|
+
column_index = r.fnumber(column)
|
15
|
+
one = (r.nfields == 2)
|
16
|
+
rescue ArgumentError
|
17
|
+
raise Error, "Can't find column #{column.inspect}"
|
18
|
+
end
|
19
|
+
|
20
|
+
h = {}
|
21
|
+
r.each_row { |row|
|
22
|
+
column_value = row.delete_at(column_index)
|
23
|
+
(h[column_value] ||= []) << (one ? row.first : row)
|
24
|
+
}
|
25
|
+
h
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
o Use enumerators
|
2
33
|
o Use SQL parameters. Optionally with a different syntax:
|
3
34
|
$var - Value that gets single-quoted
|
4
35
|
@var - Identifier that gets double-quoted (@ for "attribute")
|
@@ -30,8 +30,8 @@ module PgConn
|
|
30
30
|
end
|
31
31
|
|
32
32
|
# Drop a database
|
33
|
-
def drop(database)
|
34
|
-
conn.execute "drop database if exists \"#{database}\""
|
33
|
+
def drop(database, force: false)
|
34
|
+
conn.execute "drop database if exists \"#{database}\"#{force ? ' with (force)' : ''}"
|
35
35
|
true
|
36
36
|
end
|
37
37
|
|
data/lib/pg_conn/version.rb
CHANGED
data/lib/pg_conn.rb
CHANGED
@@ -392,7 +392,7 @@ module PgConn
|
|
392
392
|
|
393
393
|
# Return a hash from the record id column to an OpenStruct representation
|
394
394
|
# of the record. If the :key_column option is defined it will be used
|
395
|
-
# instead of id as the key It is an error if the id field value is not
|
395
|
+
# instead of id as the key. It is an error if the id field value is not
|
396
396
|
# unique
|
397
397
|
def set(query, key_column: :id)
|
398
398
|
key_column = key_column.to_sym
|
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.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claus Rasmussen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|