pg_conn 0.5.0 → 0.6.0
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
- data/pg_conn.gemspec +0 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68ebf4013a0428bd6cefd0b14606c7de75e5ae1ba96c0207a681e0899bc3f86a
|
4
|
+
data.tar.gz: eab9bc8adfd76c5c23e0b97ffad7ee4e17109d2fd4edc41f0d95e144147acd2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b548cfd9713d4f0bfebb5ef137669ea74bc81bcf963f0bdf4b1492b064dac30f429622d025830c42b921ebe26594d1df2210b682482ce36dec510f61e69e190f
|
7
|
+
data.tar.gz: 80baaeaac8744d89017de61106bb0efa32f0d6bcdd817a95d0dcac35454695e49b25d3ff2d7e04e44827ca08904971c2ef0e3d45b42c0c7a6b70c060c8055346
|
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
|
data/pg_conn.gemspec
CHANGED
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.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:
|
11
|
+
date: 2024-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -99,7 +99,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
99
|
requirements:
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
102
|
+
version: '0'
|
103
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
104
|
requirements:
|
105
105
|
- - ">="
|