pg 1.3.4 → 1.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.appveyor.yml +15 -9
  4. data/.github/workflows/binary-gems.yml +43 -12
  5. data/.github/workflows/source-gem.yml +28 -20
  6. data/.gitignore +11 -2
  7. data/.travis.yml +2 -2
  8. data/{History.rdoc → History.md} +293 -122
  9. data/README.ja.md +276 -0
  10. data/README.md +286 -0
  11. data/Rakefile +15 -6
  12. data/Rakefile.cross +7 -11
  13. data/certs/larskanis-2023.pem +24 -0
  14. data/ext/errorcodes.def +4 -0
  15. data/ext/errorcodes.txt +2 -1
  16. data/ext/pg.c +14 -54
  17. data/ext/pg.h +11 -5
  18. data/ext/pg_binary_decoder.c +80 -1
  19. data/ext/pg_binary_encoder.c +225 -1
  20. data/ext/pg_coder.c +17 -8
  21. data/ext/pg_connection.c +380 -250
  22. data/ext/pg_copy_coder.c +307 -18
  23. data/ext/pg_errors.c +1 -1
  24. data/ext/pg_record_coder.c +12 -9
  25. data/ext/pg_result.c +104 -27
  26. data/ext/pg_text_decoder.c +28 -10
  27. data/ext/pg_text_encoder.c +23 -10
  28. data/ext/pg_tuple.c +35 -32
  29. data/ext/pg_type_map.c +4 -3
  30. data/ext/pg_type_map_all_strings.c +3 -3
  31. data/ext/pg_type_map_by_class.c +6 -4
  32. data/ext/pg_type_map_by_column.c +9 -5
  33. data/ext/pg_type_map_by_mri_type.c +1 -1
  34. data/ext/pg_type_map_by_oid.c +8 -5
  35. data/ext/pg_type_map_in_ruby.c +6 -3
  36. data/lib/pg/basic_type_map_based_on_result.rb +21 -1
  37. data/lib/pg/basic_type_map_for_queries.rb +13 -8
  38. data/lib/pg/basic_type_map_for_results.rb +26 -3
  39. data/lib/pg/basic_type_registry.rb +36 -33
  40. data/lib/pg/binary_decoder/date.rb +9 -0
  41. data/lib/pg/binary_decoder/timestamp.rb +26 -0
  42. data/lib/pg/binary_encoder/timestamp.rb +20 -0
  43. data/lib/pg/coder.rb +15 -13
  44. data/lib/pg/connection.rb +265 -136
  45. data/lib/pg/exceptions.rb +14 -1
  46. data/lib/pg/text_decoder/date.rb +18 -0
  47. data/lib/pg/text_decoder/inet.rb +9 -0
  48. data/lib/pg/text_decoder/json.rb +14 -0
  49. data/lib/pg/text_decoder/numeric.rb +9 -0
  50. data/lib/pg/text_decoder/timestamp.rb +30 -0
  51. data/lib/pg/text_encoder/date.rb +12 -0
  52. data/lib/pg/text_encoder/inet.rb +28 -0
  53. data/lib/pg/text_encoder/json.rb +14 -0
  54. data/lib/pg/text_encoder/numeric.rb +9 -0
  55. data/lib/pg/text_encoder/timestamp.rb +24 -0
  56. data/lib/pg/version.rb +1 -1
  57. data/lib/pg.rb +59 -19
  58. data/pg.gemspec +4 -2
  59. data/rakelib/task_extension.rb +1 -1
  60. data/translation/.po4a-version +7 -0
  61. data/translation/po/all.pot +910 -0
  62. data/translation/po/ja.po +1047 -0
  63. data/translation/po4a.cfg +12 -0
  64. data.tar.gz.sig +0 -0
  65. metadata +101 -32
  66. metadata.gz.sig +0 -0
  67. data/README.ja.rdoc +0 -13
  68. data/README.rdoc +0 -214
  69. data/lib/pg/binary_decoder.rb +0 -23
  70. data/lib/pg/constants.rb +0 -12
  71. data/lib/pg/text_decoder.rb +0 -46
  72. data/lib/pg/text_encoder.rb +0 -59
@@ -0,0 +1,12 @@
1
+ [po_directory] po
2
+
3
+ [options] --master-charset UTF-8 \
4
+ --localized-charset UTF-8 \
5
+ --master-language en \
6
+ --option markdown \
7
+ --keep 0 \
8
+ --package-name Pg \
9
+ --package-version 1.4.6 \
10
+ --copyright-holder 'Pg authors'
11
+
12
+ [type:text] ../README.md ja:../README.ja.md
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
8
8
  - Lars Kanis
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain:
12
12
  - |
13
13
  -----BEGIN CERTIFICATE-----
14
- MIIETTCCArWgAwIBAgIBATANBgkqhkiG9w0BAQsFADAoMSYwJAYDVQQDDB1sYXJz
15
- L0RDPWdyZWl6LXJlaW5zZG9yZi9EQz1kZTAeFw0yMjAyMTQxMzMwNTZaFw0yMzAy
16
- MTQxMzMwNTZaMCgxJjAkBgNVBAMMHWxhcnMvREM9Z3JlaXotcmVpbnNkb3JmL0RD
14
+ MIIEBDCCAmygAwIBAgIBAjANBgkqhkiG9w0BAQsFADAoMSYwJAYDVQQDDB1sYXJz
15
+ L0RDPWdyZWl6LXJlaW5zZG9yZi9EQz1kZTAeFw0yMzAyMTUxNzQxMTVaFw0yNDAy
16
+ MTUxNzQxMTVaMCgxJjAkBgNVBAMMHWxhcnMvREM9Z3JlaXotcmVpbnNkb3JmL0RD
17
17
  PWRlMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAwum6Y1KznfpzXOT/
18
18
  mZgJTBbxZuuZF49Fq3K0WA67YBzNlDv95qzSp7V/7Ek3NCcnT7G+2kSuhNo1FhdN
19
19
  eSDO/moYebZNAcu3iqLsuzuULXPLuoU0GsMnVMqV9DZPh7cQHE5EBZ7hlzDBK7k/
@@ -22,21 +22,19 @@ cert_chain:
22
22
  JMNDFsmHK/6Ji4Kk48Z3TyscHQnipAID5GhS1oD21/WePdj7GhmbF5gBzkV5uepd
23
23
  eJQPgWGwrQW/Z2oPjRuJrRofzWfrMWqbOahj9uth6WSxhNexUtbjk6P8emmXOJi5
24
24
  chQPnWX+N3Gj+jjYxqTFdwT7Mj3pv1VHa+aNUbqSPpvJeDyxRIuo9hvzDaBHb/Cg
25
- 9qRVcm8a96n4t7y2lrX1oookY6bkBaxWOMtWlqIprq8JZXM9AgMBAAGjgYEwfzAJ
26
- BgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUOIdbSMr3VFrTCO9/cTM0
27
- 0exHzBcwIgYDVR0RBBswGYEXbGFyc0BncmVpei1yZWluc2RvcmYuZGUwIgYDVR0S
28
- BBswGYEXbGFyc0BncmVpei1yZWluc2RvcmYuZGUwDQYJKoZIhvcNAQELBQADggGB
29
- AFWP7F/y3Oq3NgrqUOnjKOeDaBa7AqNhHS+PZg+C90lnJzMgOs4KKgZYxqSQVSab
30
- SCEmzIO/StkXY4NpJ4fYLrHemf/fJy1wPyu+fNdp5SEEUwEo+2toRFlzTe4u4LdS
31
- QC636nPPTMt8H3xz2wf/lUIUeo2Qc95Qt2BQM465ibbG9kmA3c7Sopx6yOabYOAl
32
- KPRbOSEPiWYcF9Suuz8Gdf8jxEtPlnZiwRvnYJ+IHMq3XQCJWPpMzdDMbtlgHbXE
33
- vq1zOTLMSYAS0UB3uionR4yo1hLz60odwkCm7qf0o2Ci/5OjtB0a89VuyqRU2vUJ
34
- QH95WBjDJ6lCCW7J0mrMPnJQSUFTmufsU6jOChvPaCeAzW1YwrsP/YKnvwueG7ip
35
- VOdW6RitjtFxhS7evRL0201+KUvLz12zZWWjOcujlQs64QprxOtiv/MiisKb1Ng+
36
- oL1mUdzB8KrZL4/WbG5YNX6UTtJbIOu9qEFbBAy4/jtIkJX+dlNoFwd4GXQW1YNO
37
- nA==
25
+ 9qRVcm8a96n4t7y2lrX1oookY6bkBaxWOMtWlqIprq8JZXM9AgMBAAGjOTA3MAkG
26
+ A1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBQ4h1tIyvdUWtMI739xMzTR
27
+ 7EfMFzANBgkqhkiG9w0BAQsFAAOCAYEAQAcuTARfiiVUVx5KURICfdTM2Kd7LhOn
28
+ qt3Vs4ANGvT226LEp3RnQ+kWGQYMRb3cw3LY2TNQRPlnZxE994mgjBscN4fbjXqO
29
+ T0JbVpeszRZa5k1goggbnWT7CO7yU7WcHh13DaSubY7HUpAJn2xz9w2stxQfN/EE
30
+ VMlnDJ1P7mUHAvpK8X9j9h7Xlc1niViT18MYwux8mboVTryrLr+clATUkkM3yBF0
31
+ RV+c34ReW5eXO9Tr6aKTxh/pFC9ggDT6jOxuJgSvG8HWJzVf4NDvMavIas4KYjiI
32
+ BU6CpWaG5NxicqL3BERi52U43HV08br+LNVpb7Rekgve/PJuSFnAR015bhSRXe5U
33
+ vBioD1qW2ZW9tXg8Ww2IfDaO5a1So5Xby51rhNlyo6ATj2NkuLWZUKPKHhAz0TKm
34
+ Dzx/gFSOrRoCt2mXNgrmcAfr386AfaMvCh7cXqdxZwmVo7ILZCYXck0pajvubsDd
35
+ NUIIFkVXvd1odFyK9LF1RFAtxn/iAmpx
38
36
  -----END CERTIFICATE-----
39
- date: 2022-03-10 00:00:00.000000000 Z
37
+ date: 2023-04-28 00:00:00.000000000 Z
40
38
  dependencies: []
41
39
  description: Pg is the Ruby interface to the PostgreSQL RDBMS. It works with PostgreSQL
42
40
  9.3 and later.
@@ -46,7 +44,62 @@ email:
46
44
  executables: []
47
45
  extensions:
48
46
  - ext/extconf.rb
49
- extra_rdoc_files: []
47
+ extra_rdoc_files:
48
+ - Contributors.rdoc
49
+ - History.md
50
+ - README-OS_X.rdoc
51
+ - README-Windows.rdoc
52
+ - README.ja.md
53
+ - README.md
54
+ - ext/gvl_wrappers.c
55
+ - ext/gvl_wrappers.h
56
+ - ext/pg.c
57
+ - ext/pg.h
58
+ - ext/pg_binary_decoder.c
59
+ - ext/pg_binary_encoder.c
60
+ - ext/pg_coder.c
61
+ - ext/pg_connection.c
62
+ - ext/pg_copy_coder.c
63
+ - ext/pg_errors.c
64
+ - ext/pg_record_coder.c
65
+ - ext/pg_result.c
66
+ - ext/pg_text_decoder.c
67
+ - ext/pg_text_encoder.c
68
+ - ext/pg_tuple.c
69
+ - ext/pg_type_map.c
70
+ - ext/pg_type_map_all_strings.c
71
+ - ext/pg_type_map_by_class.c
72
+ - ext/pg_type_map_by_column.c
73
+ - ext/pg_type_map_by_mri_type.c
74
+ - ext/pg_type_map_by_oid.c
75
+ - ext/pg_type_map_in_ruby.c
76
+ - ext/pg_util.c
77
+ - ext/pg_util.h
78
+ - lib/pg.rb
79
+ - lib/pg/basic_type_map_based_on_result.rb
80
+ - lib/pg/basic_type_map_for_queries.rb
81
+ - lib/pg/basic_type_map_for_results.rb
82
+ - lib/pg/basic_type_registry.rb
83
+ - lib/pg/binary_decoder/date.rb
84
+ - lib/pg/binary_decoder/timestamp.rb
85
+ - lib/pg/binary_encoder/timestamp.rb
86
+ - lib/pg/coder.rb
87
+ - lib/pg/connection.rb
88
+ - lib/pg/exceptions.rb
89
+ - lib/pg/result.rb
90
+ - lib/pg/text_decoder/date.rb
91
+ - lib/pg/text_decoder/inet.rb
92
+ - lib/pg/text_decoder/json.rb
93
+ - lib/pg/text_decoder/numeric.rb
94
+ - lib/pg/text_decoder/timestamp.rb
95
+ - lib/pg/text_encoder/date.rb
96
+ - lib/pg/text_encoder/inet.rb
97
+ - lib/pg/text_encoder/json.rb
98
+ - lib/pg/text_encoder/numeric.rb
99
+ - lib/pg/text_encoder/timestamp.rb
100
+ - lib/pg/tuple.rb
101
+ - lib/pg/type_map_by_column.rb
102
+ - lib/pg/version.rb
50
103
  files:
51
104
  - ".appveyor.yml"
52
105
  - ".gems"
@@ -63,18 +116,19 @@ files:
63
116
  - BSDL
64
117
  - Contributors.rdoc
65
118
  - Gemfile
66
- - History.rdoc
119
+ - History.md
67
120
  - LICENSE
68
121
  - Manifest.txt
69
122
  - POSTGRES
70
123
  - README-OS_X.rdoc
71
124
  - README-Windows.rdoc
72
- - README.ja.rdoc
73
- - README.rdoc
125
+ - README.ja.md
126
+ - README.md
74
127
  - Rakefile
75
128
  - Rakefile.cross
76
129
  - certs/ged.pem
77
130
  - certs/larskanis-2022.pem
131
+ - certs/larskanis-2023.pem
78
132
  - ext/errorcodes.def
79
133
  - ext/errorcodes.rb
80
134
  - ext/errorcodes.txt
@@ -111,14 +165,23 @@ files:
111
165
  - lib/pg/basic_type_map_for_queries.rb
112
166
  - lib/pg/basic_type_map_for_results.rb
113
167
  - lib/pg/basic_type_registry.rb
114
- - lib/pg/binary_decoder.rb
168
+ - lib/pg/binary_decoder/date.rb
169
+ - lib/pg/binary_decoder/timestamp.rb
170
+ - lib/pg/binary_encoder/timestamp.rb
115
171
  - lib/pg/coder.rb
116
172
  - lib/pg/connection.rb
117
- - lib/pg/constants.rb
118
173
  - lib/pg/exceptions.rb
119
174
  - lib/pg/result.rb
120
- - lib/pg/text_decoder.rb
121
- - lib/pg/text_encoder.rb
175
+ - lib/pg/text_decoder/date.rb
176
+ - lib/pg/text_decoder/inet.rb
177
+ - lib/pg/text_decoder/json.rb
178
+ - lib/pg/text_decoder/numeric.rb
179
+ - lib/pg/text_decoder/timestamp.rb
180
+ - lib/pg/text_encoder/date.rb
181
+ - lib/pg/text_encoder/inet.rb
182
+ - lib/pg/text_encoder/json.rb
183
+ - lib/pg/text_encoder/numeric.rb
184
+ - lib/pg/text_encoder/timestamp.rb
122
185
  - lib/pg/tuple.rb
123
186
  - lib/pg/type_map_by_column.rb
124
187
  - lib/pg/version.rb
@@ -154,18 +217,24 @@ files:
154
217
  - sample/test_binary_values.rb
155
218
  - sample/wal_shipper.rb
156
219
  - sample/warehouse_partitions.rb
220
+ - translation/.po4a-version
221
+ - translation/po/all.pot
222
+ - translation/po/ja.po
223
+ - translation/po4a.cfg
157
224
  homepage: https://github.com/ged/ruby-pg
158
225
  licenses:
159
226
  - BSD-2-Clause
160
227
  metadata:
161
228
  homepage_uri: https://github.com/ged/ruby-pg
162
229
  source_code_uri: https://github.com/ged/ruby-pg
163
- changelog_uri: https://github.com/ged/ruby-pg/blob/master/History.rdoc
230
+ changelog_uri: https://github.com/ged/ruby-pg/blob/master/History.md
164
231
  documentation_uri: http://deveiate.org/code/pg
165
- post_install_message:
232
+ post_install_message:
166
233
  rdoc_options:
167
234
  - "--main"
168
- - README.rdoc
235
+ - README.md
236
+ - "--title"
237
+ - 'PG: The Ruby PostgreSQL Driver'
169
238
  require_paths:
170
239
  - lib
171
240
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -179,8 +248,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
248
  - !ruby/object:Gem::Version
180
249
  version: '0'
181
250
  requirements: []
182
- rubygems_version: 3.2.15
183
- signing_key:
251
+ rubygems_version: 3.4.6
252
+ signing_key:
184
253
  specification_version: 4
185
254
  summary: Pg is the Ruby interface to the PostgreSQL RDBMS
186
255
  test_files: []
metadata.gz.sig CHANGED
Binary file
data/README.ja.rdoc DELETED
@@ -1,13 +0,0 @@
1
- = pg
2
-
3
- home :: https://github.com/ged/ruby-pg
4
- docs :: http://deveiate.org/code/pg
5
-
6
-
7
- == Description
8
-
9
- This file needs a translation of the English README. Pull requests, patches, or
10
- volunteers gladly accepted.
11
-
12
- Until such time, please accept my sincere apologies for not knowing Japanese.
13
-
data/README.rdoc DELETED
@@ -1,214 +0,0 @@
1
- = pg
2
-
3
- home :: https://github.com/ged/ruby-pg
4
- docs :: http://deveiate.org/code/pg
5
- clog :: link:/History.rdoc
6
-
7
- {<img src="https://badges.gitter.im/Join%20Chat.svg" alt="Join the chat at https://gitter.im/ged/ruby-pg">}[https://gitter.im/ged/ruby-pg?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge]
8
-
9
-
10
- == Description
11
-
12
- Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/].
13
-
14
- It works with {PostgreSQL 9.3 and later}[http://www.postgresql.org/support/versioning/].
15
-
16
- A small example usage:
17
-
18
- #!/usr/bin/env ruby
19
-
20
- require 'pg'
21
-
22
- # Output a table of current connections to the DB
23
- conn = PG.connect( dbname: 'sales' )
24
- conn.exec( "SELECT * FROM pg_stat_activity" ) do |result|
25
- puts " PID | User | Query"
26
- result.each do |row|
27
- puts " %7d | %-16s | %s " %
28
- row.values_at('pid', 'usename', 'query')
29
- end
30
- end
31
-
32
- == Build Status
33
-
34
- {<img src="https://github.com/ged/ruby-pg/actions/workflows/source-gem.yml/badge.svg?branch=master" alt="Build Status Github Actions" />}[https://github.com/ged/ruby-pg/actions/workflows/source-gem.yml]
35
- {<img src="https://ci.appveyor.com/api/projects/status/gjx5axouf3b1wicp?svg=true" alt="Build Status Appveyor" />}[https://ci.appveyor.com/project/ged/ruby-pg-9j8l3]
36
- {<img src="https://app.travis-ci.com/larskanis/ruby-pg.svg?branch=master" alt="Build Status" />}[https://app.travis-ci.com/larskanis/ruby-pg]
37
-
38
- == Requirements
39
-
40
- * Ruby 2.4 or newer
41
- * PostgreSQL 9.3.x or later (with headers, -dev packages, etc).
42
-
43
- It usually works with earlier versions of Ruby/PostgreSQL as well, but those are
44
- not regularly tested.
45
-
46
-
47
- == Versioning
48
-
49
- We tag and release gems according to the {Semantic Versioning}[http://semver.org/] principle.
50
-
51
- As a result of this policy, you can (and should) specify a dependency on this gem using the {Pessimistic Version Constraint}[http://guides.rubygems.org/patterns/#pessimistic-version-constraint] with two digits of precision.
52
-
53
- For example:
54
-
55
- spec.add_dependency 'pg', '~> 1.0'
56
-
57
-
58
- == How To Install
59
-
60
- Install via RubyGems:
61
-
62
- gem install pg
63
-
64
- You may need to specify the path to the 'pg_config' program installed with
65
- Postgres:
66
-
67
- gem install pg -- --with-pg-config=<path to pg_config>
68
-
69
- If you're installing via Bundler, you can provide compile hints like so:
70
-
71
- bundle config build.pg --with-pg-config=<path to pg_config>
72
-
73
- See README-OS_X.rdoc for more information about installing under MacOS X, and
74
- README-Windows.rdoc for Windows build/installation instructions.
75
-
76
- There's also {a Google+ group}[http://goo.gl/TFy1U] and a
77
- {mailing list}[http://groups.google.com/group/ruby-pg] if you get stuck, or just
78
- want to chat about something.
79
-
80
- If you want to install as a signed gem, the public certs of the gem signers
81
- can be found in {the `certs` directory}[https://github.com/ged/ruby-pg/tree/master/certs]
82
- of the repository.
83
-
84
-
85
- == Type Casts
86
-
87
- Pg can optionally type cast result values and query parameters in Ruby or
88
- native C code. This can speed up data transfers to and from the database,
89
- because String allocations are reduced and conversions in (slower) Ruby code
90
- can be omitted.
91
-
92
- Very basic type casting can be enabled by:
93
-
94
- conn.type_map_for_results = PG::BasicTypeMapForResults.new conn
95
- # ... this works for result value mapping:
96
- conn.exec("select 1, now(), '{2,3}'::int[]").values
97
- # => [[1, 2014-09-21 20:51:56 +0200, [2, 3]]]
98
-
99
- conn.type_map_for_queries = PG::BasicTypeMapForQueries.new conn
100
- # ... and this for param value mapping:
101
- conn.exec_params("SELECT $1::text, $2::text, $3::text", [1, 1.23, [2,3]]).values
102
- # => [["1", "1.2300000000000000E+00", "{2,3}"]]
103
-
104
- But Pg's type casting is highly customizable. That's why it's divided into
105
- 2 layers:
106
-
107
- === Encoders / Decoders (ext/pg_*coder.c, lib/pg/*coder.rb)
108
-
109
- This is the lower layer, containing encoding classes that convert Ruby
110
- objects for transmission to the DBMS and decoding classes to convert
111
- received data back to Ruby objects. The classes are namespaced according
112
- to their format and direction in PG::TextEncoder, PG::TextDecoder,
113
- PG::BinaryEncoder and PG::BinaryDecoder.
114
-
115
- It is possible to assign a type OID, format code (text or binary) and
116
- optionally a name to an encoder or decoder object. It's also possible
117
- to build composite types by assigning an element encoder/decoder.
118
- PG::Coder objects can be used to set up a PG::TypeMap or alternatively
119
- to convert single values to/from their string representation.
120
-
121
- The following PostgreSQL column types are supported by ruby-pg (TE = Text Encoder, TD = Text Decoder, BE = Binary Encoder, BD = Binary Decoder):
122
- * Integer: {TE}[rdoc-ref:PG::TextEncoder::Integer], {TD}[rdoc-ref:PG::TextDecoder::Integer], {BD}[rdoc-ref:PG::BinaryDecoder::Integer] 💡 No links? Switch to {here}[https://deveiate.org/code/pg/README_rdoc.html#label-Type+Casts] 💡
123
- * BE: {Int2}[rdoc-ref:PG::BinaryEncoder::Int2], {Int4}[rdoc-ref:PG::BinaryEncoder::Int4], {Int8}[rdoc-ref:PG::BinaryEncoder::Int8]
124
- * Float: {TE}[rdoc-ref:PG::TextEncoder::Float], {TD}[rdoc-ref:PG::TextDecoder::Float], {BD}[rdoc-ref:PG::BinaryDecoder::Float]
125
- * Numeric: {TE}[rdoc-ref:PG::TextEncoder::Numeric], {TD}[rdoc-ref:PG::TextDecoder::Numeric]
126
- * Boolean: {TE}[rdoc-ref:PG::TextEncoder::Boolean], {TD}[rdoc-ref:PG::TextDecoder::Boolean], {BE}[rdoc-ref:PG::BinaryEncoder::Boolean], {BD}[rdoc-ref:PG::BinaryDecoder::Boolean]
127
- * String: {TE}[rdoc-ref:PG::TextEncoder::String], {TD}[rdoc-ref:PG::TextDecoder::String], {BE}[rdoc-ref:PG::BinaryEncoder::String], {BD}[rdoc-ref:PG::BinaryDecoder::String]
128
- * Bytea: {TE}[rdoc-ref:PG::TextEncoder::Bytea], {TD}[rdoc-ref:PG::TextDecoder::Bytea], {BE}[rdoc-ref:PG::BinaryEncoder::Bytea], {BD}[rdoc-ref:PG::BinaryDecoder::Bytea]
129
- * Base64: {TE}[rdoc-ref:PG::TextEncoder::ToBase64], {TD}[rdoc-ref:PG::TextDecoder::FromBase64], {BE}[rdoc-ref:PG::BinaryEncoder::FromBase64], {BD}[rdoc-ref:PG::BinaryDecoder::ToBase64]
130
- * Timestamp:
131
- * TE: {local}[rdoc-ref:PG::TextEncoder::TimestampWithoutTimeZone], {UTC}[rdoc-ref:PG::TextEncoder::TimestampUtc], {with-TZ}[rdoc-ref:PG::TextEncoder::TimestampWithTimeZone]
132
- * TD: {local}[rdoc-ref:PG::TextDecoder::TimestampLocal], {UTC}[rdoc-ref:PG::TextDecoder::TimestampUtc], {UTC-to-local}[rdoc-ref:PG::TextDecoder::TimestampUtcToLocal]
133
- * BD: {local}[rdoc-ref:PG::BinaryDecoder::TimestampLocal], {UTC}[rdoc-ref:PG::BinaryDecoder::TimestampUtc], {UTC-to-local}[rdoc-ref:PG::BinaryDecoder::TimestampUtcToLocal]
134
- * Date: {TE}[rdoc-ref:PG::TextEncoder::Date], {TD}[rdoc-ref:PG::TextDecoder::Date]
135
- * JSON and JSONB: {TE}[rdoc-ref:PG::TextEncoder::JSON], {TD}[rdoc-ref:PG::TextDecoder::JSON]
136
- * Inet: {TE}[rdoc-ref:PG::TextEncoder::Inet], {TD}[rdoc-ref:PG::TextDecoder::Inet]
137
- * Array: {TE}[rdoc-ref:PG::TextEncoder::Array], {TD}[rdoc-ref:PG::TextDecoder::Array]
138
- * Composite Type (also called "Row" or "Record"): {TE}[rdoc-ref:PG::TextEncoder::Record], {TD}[rdoc-ref:PG::TextDecoder::Record]
139
-
140
- The following text formats can also be encoded although they are not used as column type:
141
- * COPY input and output data: {TE}[rdoc-ref:PG::TextEncoder::CopyRow], {TD}[rdoc-ref:PG::TextDecoder::CopyRow]
142
- * Literal for insertion into SQL string: {TE}[rdoc-ref:PG::TextEncoder::QuotedLiteral]
143
- * SQL-Identifier: {TE}[rdoc-ref:PG::TextEncoder::Identifier], {TD}[rdoc-ref:PG::TextDecoder::Identifier]
144
-
145
- === PG::TypeMap and derivations (ext/pg_type_map*.c, lib/pg/type_map*.rb)
146
-
147
- A TypeMap defines which value will be converted by which encoder/decoder.
148
- There are different type map strategies, implemented by several derivations
149
- of this class. They can be chosen and configured according to the particular
150
- needs for type casting. The default type map is PG::TypeMapAllStrings.
151
-
152
- A type map can be assigned per connection or per query respectively per
153
- result set. Type maps can also be used for COPY in and out data streaming.
154
- See PG::Connection#copy_data .
155
-
156
- The following base type maps are available:
157
- * PG::TypeMapAllStrings - encodes and decodes all values to and from strings (default)
158
- * PG::TypeMapByClass - selects encoder based on the class of the value to be sent
159
- * PG::TypeMapByColumn - selects encoder and decoder by column order
160
- * PG::TypeMapByOid - selects decoder by PostgreSQL type OID
161
- * PG::TypeMapInRuby - define a custom type map in ruby
162
-
163
- The following type maps are prefilled with type mappings from the PG::BasicTypeRegistry :
164
- * PG::BasicTypeMapForResults - a PG::TypeMapByOid prefilled with decoders for common PostgreSQL column types
165
- * PG::BasicTypeMapBasedOnResult - a PG::TypeMapByOid prefilled with encoders for common PostgreSQL column types
166
- * PG::BasicTypeMapForQueries - a PG::TypeMapByClass prefilled with encoders for common Ruby value classes
167
-
168
-
169
- == Contributing
170
-
171
- To report bugs, suggest features, or check out the source with Git,
172
- {check out the project page}[https://github.com/ged/ruby-pg].
173
-
174
- After checking out the source, run:
175
-
176
- $ rake newb
177
-
178
- This task will install any missing dependencies, run the tests/specs, and
179
- generate the API documentation.
180
-
181
- The current maintainers are Michael Granger <ged@FaerieMUD.org> and
182
- Lars Kanis <lars@greiz-reinsdorf.de>.
183
-
184
-
185
- == Copying
186
-
187
- Copyright (c) 1997-2019 by the authors.
188
-
189
- * Jeff Davis <ruby-pg@j-davis.com>
190
- * Guy Decoux (ts) <decoux@moulon.inra.fr>
191
- * Michael Granger <ged@FaerieMUD.org>
192
- * Lars Kanis <lars@greiz-reinsdorf.de>
193
- * Dave Lee
194
- * Eiji Matsumoto <usagi@ruby.club.or.jp>
195
- * Yukihiro Matsumoto <matz@ruby-lang.org>
196
- * Noboru Saitou <noborus@netlab.jp>
197
-
198
- You may redistribute this software under the same terms as Ruby itself; see
199
- https://www.ruby-lang.org/en/about/license.txt or the BSDL file in the source
200
- for details.
201
-
202
- Portions of the code are from the PostgreSQL project, and are distributed
203
- under the terms of the PostgreSQL license, included in the file POSTGRES.
204
-
205
- Portions copyright LAIKA, Inc.
206
-
207
-
208
- == Acknowledgments
209
-
210
- See Contributors.rdoc for the many additional fine people that have contributed
211
- to this library over the years.
212
-
213
- We are thankful to the people at the ruby-list and ruby-dev mailing lists.
214
- And to the people who developed PostgreSQL.
@@ -1,23 +0,0 @@
1
- # -*- ruby -*-
2
- # frozen_string_literal: true
3
-
4
- module PG
5
- module BinaryDecoder
6
- # Convenience classes for timezone options
7
- class TimestampUtc < Timestamp
8
- def initialize(params={})
9
- super(params.merge(flags: PG::Coder::TIMESTAMP_DB_UTC | PG::Coder::TIMESTAMP_APP_UTC))
10
- end
11
- end
12
- class TimestampUtcToLocal < Timestamp
13
- def initialize(params={})
14
- super(params.merge(flags: PG::Coder::TIMESTAMP_DB_UTC | PG::Coder::TIMESTAMP_APP_LOCAL))
15
- end
16
- end
17
- class TimestampLocal < Timestamp
18
- def initialize(params={})
19
- super(params.merge(flags: PG::Coder::TIMESTAMP_DB_LOCAL | PG::Coder::TIMESTAMP_APP_LOCAL))
20
- end
21
- end
22
- end
23
- end # module PG
data/lib/pg/constants.rb DELETED
@@ -1,12 +0,0 @@
1
- # -*- ruby -*-
2
- # frozen_string_literal: true
3
-
4
- require 'pg' unless defined?( PG )
5
-
6
-
7
- module PG::Constants
8
-
9
- # Most of these are defined in the extension.
10
-
11
- end # module PG::Constants
12
-
@@ -1,46 +0,0 @@
1
- # -*- ruby -*-
2
- # frozen_string_literal: true
3
-
4
- require 'date'
5
- require 'json'
6
-
7
- module PG
8
- module TextDecoder
9
- class Date < SimpleDecoder
10
- def decode(string, tuple=nil, field=nil)
11
- if string =~ /\A(\d{4})-(\d\d)-(\d\d)\z/
12
- ::Date.new $1.to_i, $2.to_i, $3.to_i
13
- else
14
- string
15
- end
16
- end
17
- end
18
-
19
- class JSON < SimpleDecoder
20
- def decode(string, tuple=nil, field=nil)
21
- ::JSON.parse(string, quirks_mode: true)
22
- end
23
- end
24
-
25
- # Convenience classes for timezone options
26
- class TimestampUtc < Timestamp
27
- def initialize(params={})
28
- super(params.merge(flags: PG::Coder::TIMESTAMP_DB_UTC | PG::Coder::TIMESTAMP_APP_UTC))
29
- end
30
- end
31
- class TimestampUtcToLocal < Timestamp
32
- def initialize(params={})
33
- super(params.merge(flags: PG::Coder::TIMESTAMP_DB_UTC | PG::Coder::TIMESTAMP_APP_LOCAL))
34
- end
35
- end
36
- class TimestampLocal < Timestamp
37
- def initialize(params={})
38
- super(params.merge(flags: PG::Coder::TIMESTAMP_DB_LOCAL | PG::Coder::TIMESTAMP_APP_LOCAL))
39
- end
40
- end
41
-
42
- # For backward compatibility:
43
- TimestampWithoutTimeZone = TimestampLocal
44
- TimestampWithTimeZone = Timestamp
45
- end
46
- end # module PG
@@ -1,59 +0,0 @@
1
- # -*- ruby -*-
2
- # frozen_string_literal: true
3
-
4
- require 'json'
5
- require 'ipaddr'
6
-
7
- module PG
8
- module TextEncoder
9
- class Date < SimpleEncoder
10
- def encode(value)
11
- value.respond_to?(:strftime) ? value.strftime("%Y-%m-%d") : value
12
- end
13
- end
14
-
15
- class TimestampWithoutTimeZone < SimpleEncoder
16
- def encode(value)
17
- value.respond_to?(:strftime) ? value.strftime("%Y-%m-%d %H:%M:%S.%N") : value
18
- end
19
- end
20
-
21
- class TimestampUtc < SimpleEncoder
22
- def encode(value)
23
- value.respond_to?(:utc) ? value.utc.strftime("%Y-%m-%d %H:%M:%S.%N") : value
24
- end
25
- end
26
-
27
- class TimestampWithTimeZone < SimpleEncoder
28
- def encode(value)
29
- value.respond_to?(:strftime) ? value.strftime("%Y-%m-%d %H:%M:%S.%N %:z") : value
30
- end
31
- end
32
-
33
- class JSON < SimpleEncoder
34
- def encode(value)
35
- ::JSON.generate(value, quirks_mode: true)
36
- end
37
- end
38
-
39
- class Inet < SimpleEncoder
40
- def encode(value)
41
- case value
42
- when IPAddr
43
- default_prefix = (value.family == Socket::AF_INET ? 32 : 128)
44
- s = value.to_s
45
- if value.respond_to?(:prefix)
46
- prefix = value.prefix
47
- else
48
- range = value.to_range
49
- prefix = default_prefix - Math.log(((range.end.to_i - range.begin.to_i) + 1), 2).to_i
50
- end
51
- s << "/" << prefix.to_s if prefix != default_prefix
52
- s
53
- else
54
- value
55
- end
56
- end
57
- end
58
- end
59
- end # module PG