pg_data_encoder 0.1.7 → 0.1.8

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
  SHA1:
3
- metadata.gz: 0b19a299f91517f76fbcefc9698f35b227553c3b
4
- data.tar.gz: 9b8eb4e9ad16d91064ad597eda6ba6fcd8f55436
3
+ metadata.gz: 6934d6ca62f34e3ca38a53bdef9eb4300d616687
4
+ data.tar.gz: 04e0ec2af98f46d67072c6f2e662db470a851953
5
5
  SHA512:
6
- metadata.gz: f0746ac331e9479f80ad608507d724e8705f6e569ada612663b394270004a89f04bb8fe5aadec2aad1c0186d390f9d377f2c7d6b0edc8336fd576ab4ae163d6d
7
- data.tar.gz: 5685336f89acf111f1a1a907a968ba99d726cef7c50fbb1395246a3d34a45776840f8ac42da26a9b781ffb004e78ef28adff174eed95b90ed9886108d47b3f69
6
+ metadata.gz: 310e919ea938f3897d16ec8e7f46fc04844a31ad00b4fa0078a102eae60517be8e948cd99e213bd5f86d9ed62720ba653117b569215cafd92d06d877f3fb8067
7
+ data.tar.gz: 4cc2f6d4cf47bc15e60dddbddcd90af5bc08528d33947d236e95f8b2121d8089f7206341df923141f49ef8b99d8a6e51fac78c75f366ef9b89949ef20cbdfef6
@@ -101,7 +101,7 @@ module PgDataEncoder
101
101
  data
102
102
  when :bigint
103
103
  data.unpack("Q>").first
104
- when :float
104
+ when :float, :double
105
105
  data.unpack("G").first
106
106
  when :boolean
107
107
  v = data.unpack("C").first
@@ -120,6 +120,9 @@ module PgDataEncoder
120
120
  io.read(4) #unknown
121
121
  io.read(4) #unknown
122
122
  atype = io.read(4).unpack("N").first #string type?
123
+ if io.pos == io.size
124
+ return []
125
+ end
123
126
  size = io.read(4).unpack("N").first
124
127
  io.read(4) # should be 1 for dimension
125
128
  #p [atype, size]
@@ -149,11 +152,17 @@ module PgDataEncoder
149
152
  io = StringIO.new(data)
150
153
  fields = io.read(4).unpack("N").first
151
154
  h = {}
155
+
152
156
  0.upto(fields - 1).each {|i|
153
157
  key_size = io.read(4).unpack("N").first
154
158
  key = io.read(key_size).force_encoding("UTF-8")
155
159
  value_size = io.read(4).unpack("N").first
156
- value = io.read(value_size).force_encoding("UTF-8")
160
+ if value_size == 4294967295 # nil "\xFF\xFF\xFF\xFF"
161
+ value = nil
162
+ else
163
+ value = io.read(value_size)
164
+ value = value.force_encoding("UTF-8") if value.present?
165
+ end
157
166
  h[key] = value
158
167
  #p h
159
168
  }
@@ -173,7 +182,7 @@ module PgDataEncoder
173
182
  #p [data, d, Date.jd(d + Date.new(2000,1,1).jd)]
174
183
  Date.jd(d + Date.new(2000,1,1).jd)
175
184
  else
176
- raise "Unsupported format #{format}"
185
+ raise "Unsupported format #{type}"
177
186
  end
178
187
  end
179
188
 
@@ -1,3 +1,3 @@
1
1
  module PgDataEncoder
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_data_encoder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Brumm