pg_conn 0.5.0 → 0.6.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: 206932658b5b0391981261dec373d6366e36f0daf7a617281fc2226d21379ea2
4
- data.tar.gz: 7c42613ae06e24f6e596e360ce56bdf9f52515433ee3adf564d68d522439b01d
3
+ metadata.gz: 68ebf4013a0428bd6cefd0b14606c7de75e5ae1ba96c0207a681e0899bc3f86a
4
+ data.tar.gz: eab9bc8adfd76c5c23e0b97ffad7ee4e17109d2fd4edc41f0d95e144147acd2d
5
5
  SHA512:
6
- metadata.gz: db655488ffd8772091ea6620b76b95dbffc28efe56c6036b80fbafcbeb3e6db6ff6edc364007954aeb3fa95fbbf32c3fc6edbf2d2f87e574bda5e307d5fe5eaf
7
- data.tar.gz: 9a4333e1670a212d5255d01c45a5adb21ef75503a593f6a921345029aef37c52fa620377f492d93cc20f3ee37cf2efbbfaf41f18684e4b384037282963150f01
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
 
@@ -1,3 +1,3 @@
1
1
  module PgConn
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
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
@@ -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.5.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: 2022-07-20 00:00:00.000000000 Z
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: 2.4.0
102
+ version: '0'
103
103
  required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  requirements:
105
105
  - - ">="