db-postgres 0.6.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f6e34604ab35a726644bb1783228a2d60f01f76b0d431110ae20c5974ec3fcb
4
- data.tar.gz: e879e050b47d3975a29bc6b67e59b5837ad8b8cf067d96554eaf951a8d04198a
3
+ metadata.gz: 658c98714a3d05cf5fd68a3ff400dd705129faa0bca69795438cf911779bb131
4
+ data.tar.gz: 70c142e7f0a9e38b89def7e5c09e18477dfd53ee8ba150f682c41d8d92030316
5
5
  SHA512:
6
- metadata.gz: 7f4842d9d1c6c3e70029b9a4df1fd4e27a2a10bb4920465dddb1f25616b01ef50c67029d1666c218af68521bb9803cba5bc9b9f478e0c409c7c376e31466af92
7
- data.tar.gz: d9a04d2d4a541f44bc51493cb0509c0a2a0ad8e39a24e0803fa2e61532ab85cbbbe3c48045c01d60c76b9be88b464797626d966bfbe884dcdd2736c03ba7ee4e
6
+ metadata.gz: 6af540667a9ca3cf59229effef1ed44e36cc3e3a1ed4180b3a0d0a81bc3601ae365e8fc67c37e4b49b3a9802bbebb9615e4637cfc2349afdffe2543c752a4bdd
7
+ data.tar.gz: c72065aa005d7c5a546264a236f185ec0c113cba55e39ce9bbb3c7073de51d2e203521ce6354d88020cfa9adc3f59a24e91260738121d356dcb74fefad06f729
checksums.yaml.gz.sig ADDED
@@ -0,0 +1,5 @@
1
+ �nj�\�qH�P�]O���Գ *�9�JW A�-�#�ǡ��O Z�E��{����fփr�1�8�c\���Nq���-�;u
2
+ `�F��>���҉^��Y�WL�4�,A+3J���-����$;0��]�T<�udi���=A�܉� �b�`ڡlؑ��a3��x�_';i��5�j`�<�Q]%�nuj��z�o%2Ta�>�uD�]gb���,nj$�� �}��?�k�kKxDq�H�'w�0���s�� �ޗ���Ie;�~��&���`�Vav.�Q�\&`E��ʿ��i�J�@�w|��4��peŤ�Y�Z�Љ��W�\Qc�V��_��;��D�S��ܢ%
3
+ �Z�-ʆ��
4
+
5
+ d4�����N���3��"%ĩ��TuC�
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2018-2024, by Samuel Williams.
22
5
 
23
6
  require_relative 'connection'
24
7
 
@@ -1,28 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2018-2024, by Samuel Williams.
22
5
 
23
6
  require 'async/pool/resource'
24
- require 'async/io/generic'
25
-
26
7
  require_relative 'native/connection'
27
8
 
28
9
  module DB
@@ -36,11 +17,18 @@ module DB
36
17
  end
37
18
 
38
19
  def close
39
- @native.close
20
+ if @native
21
+ @native&.close
22
+ @native = nil
23
+ end
40
24
 
41
25
  super
42
26
  end
43
27
 
28
+ def types
29
+ @native.types
30
+ end
31
+
44
32
  def append_string(value, buffer = String.new)
45
33
  buffer << @native.escape_literal(value)
46
34
 
@@ -49,6 +37,8 @@ module DB
49
37
 
50
38
  def append_literal(value, buffer = String.new)
51
39
  case value
40
+ when Time, DateTime, Date
41
+ append_string(value.iso8601, buffer)
52
42
  when Numeric
53
43
  buffer << value.to_s
54
44
  when TrueClass
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2020-2024, by Samuel Williams.
22
5
 
23
6
  module DB
24
7
  module Postgres
@@ -1,22 +1,7 @@
1
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2018-2024, by Samuel Williams.
20
5
 
21
6
  require_relative 'result'
22
7
  require_relative 'field'
@@ -96,14 +81,8 @@ module DB
96
81
  ffi_attach_function :PQescapeLiteral, [:pointer, :string, :size_t], :pointer, as: :escape_literal
97
82
  ffi_attach_function :PQescapeIdentifier, [:pointer, :string, :size_t], :pointer, as: :escape_identifier
98
83
 
99
- module IO
100
- def self.new(fd, mode)
101
- Async::IO::Generic.new(::IO.new(fd, mode, autoclose: false))
102
- end
103
- end
104
-
105
84
  class Connection < FFI::Pointer
106
- def self.connect(wrapper: IO, types: DEFAULT_TYPES, **options)
85
+ def self.connect(types: DEFAULT_TYPES, **options)
107
86
  # Postgres expects "dbname" as the key name:
108
87
  if database = options.delete(:database)
109
88
  options[:dbname] = database
@@ -120,7 +99,7 @@ module DB
120
99
  pointer = Native.connect_start_params(keys.array, values.array, 0)
121
100
  Native.set_nonblocking(pointer, 1)
122
101
 
123
- io = wrapper.new(Native.socket(pointer), "r+")
102
+ io = ::IO.new(Native.socket(pointer), "r+", autoclose: false)
124
103
 
125
104
  while status = Native.connect_poll(pointer)
126
105
  break if status == :ok || status == :failed
@@ -149,6 +128,8 @@ module DB
149
128
  @types = types
150
129
  end
151
130
 
131
+ attr :types
132
+
152
133
  # Return the status of the connection.
153
134
  def status
154
135
  Native.status(self)
@@ -1,48 +1,64 @@
1
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2020-2024, by Samuel Williams.
20
5
 
21
6
  require_relative 'types'
22
7
 
23
8
  module DB
24
9
  module Postgres
25
10
  module Native
26
- # These are hard coded OIDs.
27
11
  DEFAULT_TYPES = {
28
- 16 => Types::Boolean,
12
+ # Pseudo types:
13
+ primary_key: Types::Integer.new('BIGSERIAL PRIMARY KEY'),
14
+ foreign_key: Types::Integer.new('BIGINT'),
15
+ text: Types::Text.new("TEXT"),
16
+ string: Types::Text.new("VARCHAR(255)"),
17
+
18
+ # Symbolic types:
19
+ decimal: Types::Decimal.new,
20
+ boolean: Types::Boolean.new,
21
+
22
+ smallint: Types::Integer.new("SMALLINT"),
23
+ integer: Types::Integer.new("INTEGER"),
24
+ bigint: Types::Integer.new("BIGINT"),
25
+
26
+ float: Types::Float.new,
27
+ double: Types::Float.new("DOUBLE"),
28
+
29
+ timestamp: Types::DateTime.new("TIMESTAMPTZ"),
30
+ date: Types::Date.new,
31
+ datetime: Types::DateTime.new("TIMESTAMPTZ"),
32
+ year: Types::Integer.new("LONG"),
33
+
34
+ json: Types::JSON.new,
35
+ enum: Types::Symbol.new,
36
+
37
+ # Native types:
38
+ # This data is extracted by hand from:
39
+ # <https://github.com/postgres/postgres/blob/master/src/include/catalog/pg_type.dat>.
40
+ # These are hard coded OIDs.
41
+ 16 => Types::Boolean.new,
42
+
43
+ 20 => Types::Integer.new("int8"),
44
+ 21 => Types::Integer.new("int2"),
45
+ 23 => Types::Integer.new("int4"),
29
46
 
30
- 20 => Types::Integer,
31
- 21 => Types::Integer,
32
- 23 => Types::Integer,
47
+ 114 => Types::JSON.new,
33
48
 
34
- 114 => Types::JSON,
49
+ 700 => Types::Float.new('float4'),
50
+ 701 => Types::Float.new('float8'),
35
51
 
36
- 700 => Types::Float,
37
- 701 => Types::Float,
52
+ 1082 => Types::Date.new,
53
+ 1083 => Types::DateTime.new("TIME"),
38
54
 
39
- 1082 => Date,
40
- 1083 => Types::DateTime,
41
- 1114 => Types::DateTime,
55
+ 1114 => Types::DateTime.new("TIMESTAMP"),
56
+ 1184 => Types::DateTime.new("TIMESTAMPTZ"),
42
57
 
43
- 1700 => Types::Decimal,
58
+ 1700 => Types::Decimal.new,
44
59
 
45
- 3500 => Types::Symbol,
60
+ # Not sure if this is ever used?
61
+ 3500 => Types::Symbol.new,
46
62
  }
47
63
  end
48
64
  end
@@ -1,22 +1,7 @@
1
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2018-2024, by Samuel Williams.
20
5
 
21
6
  require_relative '../native'
22
7
 
@@ -1,75 +1,127 @@
1
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
20
2
 
21
- require 'ffi'
3
+ # Released under the MIT License.
4
+ # Copyright, 2020-2024, by Samuel Williams.
22
5
 
23
6
  require 'json'
24
7
  require 'bigdecimal'
25
- require 'time'
26
8
 
27
9
  module DB
28
10
  module Postgres
29
11
  module Native
30
12
  module Types
31
- module Boolean
32
- def self.parse(string)
33
- string == 't'
13
+ class Text
14
+ def initialize(name = "TEXT")
15
+ @name = name
16
+ end
17
+
18
+ attr :name
19
+
20
+ def parse(string)
21
+ string
34
22
  end
35
23
  end
36
24
 
37
- module Integer
38
- def self.parse(string)
25
+ class Integer
26
+ def initialize(name = "INTEGER")
27
+ @name = name
28
+ end
29
+
30
+ attr :name
31
+
32
+ def parse(string)
39
33
  Integer(string) if string
40
34
  end
41
35
  end
42
36
 
43
- module Decimal
44
- def self.parse(string)
37
+ class Boolean
38
+ def name
39
+ "BOOLEAN"
40
+ end
41
+
42
+ def parse(string)
43
+ string == 't'
44
+ end
45
+ end
46
+
47
+ class Decimal
48
+ def name
49
+ "DECIMAL"
50
+ end
51
+
52
+ def parse(string)
45
53
  BigDecimal(string) if string
46
54
  end
47
55
  end
48
56
 
49
- module Float
50
- def self.parse(string)
57
+ class Float
58
+ def initialize(name = "FLOAT")
59
+ @name = name
60
+ end
61
+
62
+ attr :name
63
+
64
+ def parse(string)
51
65
  Float(string) if string
52
66
  end
53
67
  end
54
68
 
55
- module Symbol
56
- def self.parse(string)
69
+ class Symbol
70
+ def name
71
+ "ENUM"
72
+ end
73
+
74
+ def parse(string)
57
75
  string&.to_sym
58
76
  end
59
77
  end
60
78
 
61
- module DateTime
62
- def self.parse(string)
79
+ class DateTime
80
+ def initialize(name = "TIMESTAMP")
81
+ @name = name
82
+ end
83
+
84
+ attr :name
85
+
86
+ def parse(string)
87
+ if string == '-infinity' || string == 'infinity' || string.nil?
88
+ return string
89
+ end
90
+
91
+ if match = string.match(/\A(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+(?:\.\d+)?)([-+]\d\d(?::\d\d)?)?\z/)
92
+ parts = match.captures
93
+
94
+ parts[5] = Rational(parts[5])
95
+
96
+ if parts[6].nil?
97
+ parts[6] = '+00'
98
+ end
99
+
100
+ return Time.new(*parts)
101
+ end
102
+ end
103
+ end
104
+
105
+ class Date
106
+ def name
107
+ "DATE"
108
+ end
109
+
110
+ def parse(string)
63
111
  if string
64
- parts = string.split(/[\-\s:\.]/)
112
+ parts = string.split(/[\-\s:]/)
65
113
 
66
114
  return Time.utc(*parts)
67
115
  end
68
116
  end
69
117
  end
70
118
 
71
- module JSON
72
- def self.parse(string)
119
+ class JSON
120
+ def name
121
+ "JSON"
122
+ end
123
+
124
+ def parse(string)
73
125
  ::JSON.parse(string, symbolize_names: true) if string
74
126
  end
75
127
  end
@@ -1,32 +1,17 @@
1
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
20
2
 
21
- require 'ffi/module'
22
- require 'ffi/module/config_tool'
3
+ # Released under the MIT License.
4
+ # Copyright, 2018-2024, by Samuel Williams.
5
+
6
+ require 'ffi/native'
7
+ require 'ffi/native/config_tool'
23
8
 
24
9
  module DB
25
10
  module Postgres
26
11
  module Native
27
- extend FFI::Module::Library
28
- extend FFI::Module::Loader
29
- extend FFI::Module::ConfigTool
12
+ extend FFI::Native::Library
13
+ extend FFI::Native::Loader
14
+ extend FFI::Native::ConfigTool
30
15
 
31
16
  ffi_load('pq') ||
32
17
  ffi_load_using_config_tool(%w{pg_config --libdir}, names: ['pq']) ||
@@ -1,25 +1,10 @@
1
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2018-2024, by Samuel Williams.
20
5
 
21
6
  module DB
22
7
  module Postgres
23
- VERSION = "0.6.0"
8
+ VERSION = "0.8.0"
24
9
  end
25
10
  end
data/lib/db/postgres.rb CHANGED
@@ -1,22 +1,7 @@
1
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2018-2024, by Samuel Williams.
20
5
 
21
6
  require_relative 'postgres/native'
22
7
  require_relative 'postgres/connection'
data/license.md ADDED
@@ -0,0 +1,23 @@
1
+ # MIT License
2
+
3
+ Copyright, 2018-2024, by Samuel Williams.
4
+ Copyright, 2021, by Tony Schneider.
5
+ Copyright, 2022, by Aidan Samuel.
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
data/readme.md ADDED
@@ -0,0 +1,29 @@
1
+ # DB::Postgres
2
+
3
+ A light-weight wrapper for Ruby connecting to Postgres servers. This gem provides an adapter for the [`db` gem](https://github.com/socketry/db). You should use the `db` gem directly as it provides a unified interface for all database adapters and contains the majority of the documentation.
4
+
5
+ [![Development Status](https://github.com/socketry/db-postgres/workflows/Test/badge.svg)](https://github.com/socketry/db-postgres/actions?workflow=Test)
6
+
7
+ ## Usage
8
+
9
+ Please see the [project documentation](https://socketry.github.io/db-postgres/) for more details.
10
+
11
+ - [Getting Started](https://socketry.github.io/db-postgres/guides/getting-started/index) - This guide explains how to get started with the `db-postgres` gem.
12
+
13
+ ## Contributing
14
+
15
+ We welcome contributions to this project.
16
+
17
+ 1. Fork it.
18
+ 2. Create your feature branch (`git checkout -b my-new-feature`).
19
+ 3. Commit your changes (`git commit -am 'Add some feature'`).
20
+ 4. Push to the branch (`git push origin my-new-feature`).
21
+ 5. Create new Pull Request.
22
+
23
+ ### Developer Certificate of Origin
24
+
25
+ In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
26
+
27
+ ### Community Guidelines
28
+
29
+ This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
data.tar.gz.sig ADDED
Binary file
metadata CHANGED
@@ -1,43 +1,46 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: db-postgres
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
+ - Aidan Samuel
9
+ - Tony Schneider
8
10
  autorequire:
9
11
  bindir: bin
10
- cert_chain: []
11
- date: 2021-05-23 00:00:00.000000000 Z
12
+ cert_chain:
13
+ - |
14
+ -----BEGIN CERTIFICATE-----
15
+ MIIE2DCCA0CgAwIBAgIBATANBgkqhkiG9w0BAQsFADBhMRgwFgYDVQQDDA9zYW11
16
+ ZWwud2lsbGlhbXMxHTAbBgoJkiaJk/IsZAEZFg1vcmlvbnRyYW5zZmVyMRIwEAYK
17
+ CZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJuejAeFw0yMjA4MDYwNDUz
18
+ MjRaFw0zMjA4MDMwNDUzMjRaMGExGDAWBgNVBAMMD3NhbXVlbC53aWxsaWFtczEd
19
+ MBsGCgmSJomT8ixkARkWDW9yaW9udHJhbnNmZXIxEjAQBgoJkiaJk/IsZAEZFgJj
20
+ bzESMBAGCgmSJomT8ixkARkWAm56MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIB
21
+ igKCAYEAomvSopQXQ24+9DBB6I6jxRI2auu3VVb4nOjmmHq7XWM4u3HL+pni63X2
22
+ 9qZdoq9xt7H+RPbwL28LDpDNflYQXoOhoVhQ37Pjn9YDjl8/4/9xa9+NUpl9XDIW
23
+ sGkaOY0eqsQm1pEWkHJr3zn/fxoKPZPfaJOglovdxf7dgsHz67Xgd/ka+Wo1YqoE
24
+ e5AUKRwUuvaUaumAKgPH+4E4oiLXI4T1Ff5Q7xxv6yXvHuYtlMHhYfgNn8iiW8WN
25
+ XibYXPNP7NtieSQqwR/xM6IRSoyXKuS+ZNGDPUUGk8RoiV/xvVN4LrVm9upSc0ss
26
+ RZ6qwOQmXCo/lLcDUxJAgG95cPw//sI00tZan75VgsGzSWAOdjQpFM0l4dxvKwHn
27
+ tUeT3ZsAgt0JnGqNm2Bkz81kG4A2hSyFZTFA8vZGhp+hz+8Q573tAR89y9YJBdYM
28
+ zp0FM4zwMNEUwgfRzv1tEVVUEXmoFCyhzonUUw4nE4CFu/sE3ffhjKcXcY//qiSW
29
+ xm4erY3XAgMBAAGjgZowgZcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0O
30
+ BBYEFO9t7XWuFf2SKLmuijgqR4sGDlRsMC4GA1UdEQQnMCWBI3NhbXVlbC53aWxs
31
+ aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MC4GA1UdEgQnMCWBI3NhbXVlbC53aWxs
32
+ aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MA0GCSqGSIb3DQEBCwUAA4IBgQB5sxkE
33
+ cBsSYwK6fYpM+hA5B5yZY2+L0Z+27jF1pWGgbhPH8/FjjBLVn+VFok3CDpRqwXCl
34
+ xCO40JEkKdznNy2avOMra6PFiQyOE74kCtv7P+Fdc+FhgqI5lMon6tt9rNeXmnW/
35
+ c1NaMRdxy999hmRGzUSFjozcCwxpy/LwabxtdXwXgSay4mQ32EDjqR1TixS1+smp
36
+ 8C/NCWgpIfzpHGJsjvmH2wAfKtTTqB9CVKLCWEnCHyCaRVuKkrKjqhYCdmMBqCws
37
+ JkxfQWC+jBVeG9ZtPhQgZpfhvh+6hMhraUYRQ6XGyvBqEUe+yo6DKIT3MtGE2+CP
38
+ eX9i9ZWBydWb8/rvmwmX2kkcBbX0hZS1rcR593hGc61JR6lvkGYQ2MYskBveyaxt
39
+ Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
40
+ voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
41
+ -----END CERTIFICATE-----
42
+ date: 2024-07-27 00:00:00.000000000 Z
12
43
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: ffi-module
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 0.3.0
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 0.3.0
27
- - !ruby/object:Gem::Dependency
28
- name: async-io
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
44
  - !ruby/object:Gem::Dependency
42
45
  name: async-pool
43
46
  requirement: !ruby/object:Gem::Requirement
@@ -53,82 +56,25 @@ dependencies:
53
56
  - !ruby/object:Gem::Version
54
57
  version: '0'
55
58
  - !ruby/object:Gem::Dependency
56
- name: async-rspec
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: bake
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: covered
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: bundler
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: rspec
59
+ name: ffi-native
113
60
  requirement: !ruby/object:Gem::Requirement
114
61
  requirements:
115
62
  - - "~>"
116
63
  - !ruby/object:Gem::Version
117
- version: '3.6'
118
- type: :development
64
+ version: '0.4'
65
+ type: :runtime
119
66
  prerelease: false
120
67
  version_requirements: !ruby/object:Gem::Requirement
121
68
  requirements:
122
69
  - - "~>"
123
70
  - !ruby/object:Gem::Version
124
- version: '3.6'
71
+ version: '0.4'
125
72
  description:
126
73
  email:
127
74
  executables: []
128
75
  extensions: []
129
76
  extra_rdoc_files: []
130
77
  files:
131
- - lib/.DS_Store
132
78
  - lib/db/postgres.rb
133
79
  - lib/db/postgres/adapter.rb
134
80
  - lib/db/postgres/connection.rb
@@ -139,10 +85,15 @@ files:
139
85
  - lib/db/postgres/native/result.rb
140
86
  - lib/db/postgres/native/types.rb
141
87
  - lib/db/postgres/version.rb
142
- homepage:
88
+ - license.md
89
+ - readme.md
90
+ homepage: https://github.com/socketry/db-postgres
143
91
  licenses:
144
92
  - MIT
145
- metadata: {}
93
+ metadata:
94
+ documentation_uri: https://socketry.github.io/db-postgres/
95
+ funding_uri: https://github.com/sponsors/ioquatix
96
+ source_code_uri: https://github.com/socketry/db-postgres.git
146
97
  post_install_message:
147
98
  rdoc_options: []
148
99
  require_paths:
@@ -151,14 +102,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
151
102
  requirements:
152
103
  - - ">="
153
104
  - !ruby/object:Gem::Version
154
- version: '2.5'
105
+ version: '3.1'
155
106
  required_rubygems_version: !ruby/object:Gem::Requirement
156
107
  requirements:
157
108
  - - ">="
158
109
  - !ruby/object:Gem::Version
159
110
  version: '0'
160
111
  requirements: []
161
- rubygems_version: 3.2.3
112
+ rubygems_version: 3.5.11
162
113
  signing_key:
163
114
  specification_version: 4
164
115
  summary: Ruby FFI bindings for libpq C interface.
metadata.gz.sig ADDED
@@ -0,0 +1,4 @@
1
+ ! ��l?�6�]�#Ѹ���f\���(�y3X����]���4@��?
2
+ �-�h�C�[�l�����a{Ԍ�'�YI���"�ԗ�e,^1���3+�����J �-MO��e�|"a%1Y�e+
3
+ S^��-�P�2�W4�$�%�l���x��g!�� {���� ��qc_m�
4
+ ��:olU�^蒕�����mN����v����4����VJ:�'�fqX�I�-����a4L�c�s����C�!������ٛl66
data/lib/.DS_Store DELETED
Binary file