db-postgres 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/db/postgres/connection.rb +10 -1
- data/lib/db/postgres/native/connection.rb +2 -0
- data/lib/db/postgres/native/field.rb +44 -13
- data/lib/db/postgres/native/types.rb +76 -19
- data/lib/db/postgres/version.rb +1 -1
- data.tar.gz.sig +2 -0
- metadata +46 -19
- metadata.gz.sig +0 -0
- data/lib/.DS_Store +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ba17d708434471a3146cf704a5df1f64109ee8d914f73e7fbd07bcee83a04d0
|
4
|
+
data.tar.gz: 896c9c7c8850266ec0ec93a2f3ccbf35a70edd1bf88d6e9f15b67702338d6f66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18d4937f8998c303c2816a9a7fc990e0b9af87fc44a25f448a48f20f509fdf6738a697eeca81df043109ebc753585565c0d67c822b350350fa69b3db9248fb82
|
7
|
+
data.tar.gz: cd4a0d9ea49bbee151193bc512765631c47ea99d97ae495f96d0dd91d709b216fe70840038ec410f538aeaafc3029ba63bd9df0025193dcc2622658b4bcf569d
|
checksums.yaml.gz.sig
ADDED
Binary file
|
@@ -36,11 +36,18 @@ module DB
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def close
|
39
|
-
@native
|
39
|
+
if @native
|
40
|
+
@native&.close
|
41
|
+
@native = nil
|
42
|
+
end
|
40
43
|
|
41
44
|
super
|
42
45
|
end
|
43
46
|
|
47
|
+
def types
|
48
|
+
@native.types
|
49
|
+
end
|
50
|
+
|
44
51
|
def append_string(value, buffer = String.new)
|
45
52
|
buffer << @native.escape_literal(value)
|
46
53
|
|
@@ -49,6 +56,8 @@ module DB
|
|
49
56
|
|
50
57
|
def append_literal(value, buffer = String.new)
|
51
58
|
case value
|
59
|
+
when Time, DateTime, Date
|
60
|
+
append_string(value.iso8601, buffer)
|
52
61
|
when Numeric
|
53
62
|
buffer << value.to_s
|
54
63
|
when TrueClass
|
@@ -23,26 +23,57 @@ require_relative 'types'
|
|
23
23
|
module DB
|
24
24
|
module Postgres
|
25
25
|
module Native
|
26
|
-
# These are hard coded OIDs.
|
27
26
|
DEFAULT_TYPES = {
|
28
|
-
|
27
|
+
# Pseudo types:
|
28
|
+
primary_key: Types::Integer.new('BIGSERIAL PRIMARY KEY'),
|
29
|
+
foreign_key: Types::Integer.new('BIGINT'),
|
30
|
+
text: Types::Text.new("TEXT"),
|
31
|
+
string: Types::Text.new("VARCHAR(255)"),
|
29
32
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
+
# Symbolic types:
|
34
|
+
decimal: Types::Decimal.new,
|
35
|
+
boolean: Types::Boolean.new,
|
33
36
|
|
34
|
-
|
37
|
+
smallint: Types::Integer.new("SMALLINT"),
|
38
|
+
integer: Types::Integer.new("INTEGER"),
|
39
|
+
bigint: Types::Integer.new("BIGINT"),
|
35
40
|
|
36
|
-
|
37
|
-
|
41
|
+
float: Types::Float.new,
|
42
|
+
double: Types::Float.new("DOUBLE"),
|
38
43
|
|
39
|
-
|
40
|
-
|
41
|
-
|
44
|
+
timestamp: Types::DateTime.new("TIMESTAMP"),
|
45
|
+
date: Types::Date.new,
|
46
|
+
datetime: Types::DateTime.new("DATETIME"),
|
47
|
+
year: Types::Integer.new("LONG"),
|
42
48
|
|
43
|
-
|
49
|
+
json: Types::JSON.new,
|
50
|
+
enum: Types::Symbol.new,
|
44
51
|
|
45
|
-
|
52
|
+
# Native types:
|
53
|
+
# This data is extracted by hand from:
|
54
|
+
# <https://github.com/postgres/postgres/blob/master/src/include/catalog/pg_type.dat>.
|
55
|
+
# These are hard coded OIDs.
|
56
|
+
16 => Types::Boolean.new,
|
57
|
+
|
58
|
+
20 => Types::Integer.new("int8"),
|
59
|
+
21 => Types::Integer.new("int2"),
|
60
|
+
23 => Types::Integer.new("int4"),
|
61
|
+
|
62
|
+
114 => Types::JSON.new,
|
63
|
+
|
64
|
+
700 => Types::Float.new('float4'),
|
65
|
+
701 => Types::Float.new('float8'),
|
66
|
+
|
67
|
+
1082 => Types::Date.new,
|
68
|
+
1083 => Types::DateTime.new("TIME"),
|
69
|
+
|
70
|
+
1114 => Types::DateTime.new("TIMESTAMP"),
|
71
|
+
1184 => Types::DateTime.new("TIMESTAMPTZ"),
|
72
|
+
|
73
|
+
1700 => Types::Decimal.new,
|
74
|
+
|
75
|
+
# Not sure if this is ever used?
|
76
|
+
3500 => Types::Symbol.new,
|
46
77
|
}
|
47
78
|
end
|
48
79
|
end
|
@@ -18,58 +18,115 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
|
-
require 'ffi'
|
22
|
-
|
23
21
|
require 'json'
|
24
22
|
require 'bigdecimal'
|
25
|
-
require 'time'
|
26
23
|
|
27
24
|
module DB
|
28
25
|
module Postgres
|
29
26
|
module Native
|
30
27
|
module Types
|
31
|
-
|
32
|
-
def
|
33
|
-
|
28
|
+
class Text
|
29
|
+
def initialize(name = "TEXT")
|
30
|
+
@name = name
|
31
|
+
end
|
32
|
+
|
33
|
+
attr :name
|
34
|
+
|
35
|
+
def parse(string)
|
36
|
+
string
|
34
37
|
end
|
35
38
|
end
|
36
39
|
|
37
|
-
|
38
|
-
def
|
40
|
+
class Integer
|
41
|
+
def initialize(name = "INTEGER")
|
42
|
+
@name = name
|
43
|
+
end
|
44
|
+
|
45
|
+
attr :name
|
46
|
+
|
47
|
+
def parse(string)
|
39
48
|
Integer(string) if string
|
40
49
|
end
|
41
50
|
end
|
42
51
|
|
43
|
-
|
44
|
-
def
|
52
|
+
class Boolean
|
53
|
+
def name
|
54
|
+
"BOOLEAN"
|
55
|
+
end
|
56
|
+
|
57
|
+
def parse(string)
|
58
|
+
string == 't'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
class Decimal
|
63
|
+
def name
|
64
|
+
"DECIMAL"
|
65
|
+
end
|
66
|
+
|
67
|
+
def parse(string)
|
45
68
|
BigDecimal(string) if string
|
46
69
|
end
|
47
70
|
end
|
48
71
|
|
49
|
-
|
50
|
-
def
|
72
|
+
class Float
|
73
|
+
def initialize(name = "FLOAT")
|
74
|
+
@name = name
|
75
|
+
end
|
76
|
+
|
77
|
+
attr :name
|
78
|
+
|
79
|
+
def parse(string)
|
51
80
|
Float(string) if string
|
52
81
|
end
|
53
82
|
end
|
54
83
|
|
55
|
-
|
56
|
-
def
|
84
|
+
class Symbol
|
85
|
+
def name
|
86
|
+
"ENUM"
|
87
|
+
end
|
88
|
+
|
89
|
+
def parse(string)
|
57
90
|
string&.to_sym
|
58
91
|
end
|
59
92
|
end
|
60
93
|
|
61
|
-
|
62
|
-
def
|
94
|
+
class DateTime
|
95
|
+
def initialize(name = "TIMESTAMP")
|
96
|
+
@name = name
|
97
|
+
end
|
98
|
+
|
99
|
+
attr :name
|
100
|
+
|
101
|
+
def parse(string)
|
63
102
|
if string
|
64
|
-
parts = string.split(/[\-\s
|
103
|
+
parts = string.split(/[\-\s:]/)
|
65
104
|
|
66
105
|
return Time.utc(*parts)
|
67
106
|
end
|
68
107
|
end
|
69
108
|
end
|
70
109
|
|
71
|
-
|
72
|
-
def
|
110
|
+
class Date
|
111
|
+
def name
|
112
|
+
"DATE"
|
113
|
+
end
|
114
|
+
|
115
|
+
def parse(string)
|
116
|
+
if string
|
117
|
+
parts = string.split(/[\-\s:]/)
|
118
|
+
|
119
|
+
return Time.utc(*parts)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
class JSON
|
125
|
+
def name
|
126
|
+
"JSON"
|
127
|
+
end
|
128
|
+
|
129
|
+
def parse(string)
|
73
130
|
::JSON.parse(string, symbolize_names: true) if string
|
74
131
|
end
|
75
132
|
end
|
data/lib/db/postgres/version.rb
CHANGED
data.tar.gz.sig
ADDED
metadata
CHANGED
@@ -1,31 +1,59 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: db-postgres
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIEhDCCAuygAwIBAgIBATANBgkqhkiG9w0BAQsFADA3MTUwMwYDVQQDDCxzYW11
|
14
|
+
ZWwud2lsbGlhbXMvREM9b3Jpb250cmFuc2Zlci9EQz1jby9EQz1uejAeFw0yMTA4
|
15
|
+
MTYwNjMzNDRaFw0yMjA4MTYwNjMzNDRaMDcxNTAzBgNVBAMMLHNhbXVlbC53aWxs
|
16
|
+
aWFtcy9EQz1vcmlvbnRyYW5zZmVyL0RDPWNvL0RDPW56MIIBojANBgkqhkiG9w0B
|
17
|
+
AQEFAAOCAY8AMIIBigKCAYEAyXLSS/cw+fXJ5e7hi+U/TeChPWeYdwJojDsFY1xr
|
18
|
+
xvtqbTTL8gbLHz5LW3QD2nfwCv3qTlw0qI3Ie7a9VMJMbSvgVEGEfQirqIgJXWMj
|
19
|
+
eNMDgKsMJtC7u/43abRKx7TCURW3iWyR19NRngsJJmaR51yGGGm2Kfsr+JtKKLtL
|
20
|
+
L188Wm3f13KAx7QJU8qyuBnj1/gWem076hzdA7xi1DbrZrch9GCRz62xymJlrJHn
|
21
|
+
9iZEZ7AxrS7vokhMlzSr/XMUihx/8aFKtk+tMLClqxZSmBWIErWdicCGTULXCBNb
|
22
|
+
E/mljo4zEVKhlTWpJklMIhr55ZRrSarKFuW7en0+tpJrfsYiAmXMJNi4XAYJH7uL
|
23
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|
+
date: 2021-10-04 00:00:00.000000000 Z
|
12
40
|
dependencies:
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
42
|
+
name: async-io
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
16
44
|
requirements:
|
17
|
-
- - "
|
45
|
+
- - ">="
|
18
46
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0
|
47
|
+
version: '0'
|
20
48
|
type: :runtime
|
21
49
|
prerelease: false
|
22
50
|
version_requirements: !ruby/object:Gem::Requirement
|
23
51
|
requirements:
|
24
|
-
- - "
|
52
|
+
- - ">="
|
25
53
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0
|
54
|
+
version: '0'
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: async-
|
56
|
+
name: async-pool
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
30
58
|
requirements:
|
31
59
|
- - ">="
|
@@ -39,19 +67,19 @@ dependencies:
|
|
39
67
|
- !ruby/object:Gem::Version
|
40
68
|
version: '0'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
70
|
+
name: ffi-module
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
44
72
|
requirements:
|
45
|
-
- - "
|
73
|
+
- - "~>"
|
46
74
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
75
|
+
version: 0.3.0
|
48
76
|
type: :runtime
|
49
77
|
prerelease: false
|
50
78
|
version_requirements: !ruby/object:Gem::Requirement
|
51
79
|
requirements:
|
52
|
-
- - "
|
80
|
+
- - "~>"
|
53
81
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
82
|
+
version: 0.3.0
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: async-rspec
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,7 +109,7 @@ dependencies:
|
|
81
109
|
- !ruby/object:Gem::Version
|
82
110
|
version: '0'
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
112
|
+
name: bundler
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
86
114
|
requirements:
|
87
115
|
- - ">="
|
@@ -95,7 +123,7 @@ dependencies:
|
|
95
123
|
- !ruby/object:Gem::Version
|
96
124
|
version: '0'
|
97
125
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
126
|
+
name: covered
|
99
127
|
requirement: !ruby/object:Gem::Requirement
|
100
128
|
requirements:
|
101
129
|
- - ">="
|
@@ -128,7 +156,6 @@ executables: []
|
|
128
156
|
extensions: []
|
129
157
|
extra_rdoc_files: []
|
130
158
|
files:
|
131
|
-
- lib/.DS_Store
|
132
159
|
- lib/db/postgres.rb
|
133
160
|
- lib/db/postgres/adapter.rb
|
134
161
|
- lib/db/postgres/connection.rb
|
@@ -139,7 +166,7 @@ files:
|
|
139
166
|
- lib/db/postgres/native/result.rb
|
140
167
|
- lib/db/postgres/native/types.rb
|
141
168
|
- lib/db/postgres/version.rb
|
142
|
-
homepage:
|
169
|
+
homepage: https://github.com/socketry/db-postgres
|
143
170
|
licenses:
|
144
171
|
- MIT
|
145
172
|
metadata: {}
|
@@ -158,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
185
|
- !ruby/object:Gem::Version
|
159
186
|
version: '0'
|
160
187
|
requirements: []
|
161
|
-
rubygems_version: 3.2.
|
188
|
+
rubygems_version: 3.2.22
|
162
189
|
signing_key:
|
163
190
|
specification_version: 4
|
164
191
|
summary: Ruby FFI bindings for libpq C interface.
|
metadata.gz.sig
ADDED
Binary file
|
data/lib/.DS_Store
DELETED
Binary file
|