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 +4 -4
- data/lib/pg_data_encoder/decoder.rb +12 -3
- data/lib/pg_data_encoder/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6934d6ca62f34e3ca38a53bdef9eb4300d616687
|
4
|
+
data.tar.gz: 04e0ec2af98f46d67072c6f2e662db470a851953
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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 #{
|
185
|
+
raise "Unsupported format #{type}"
|
177
186
|
end
|
178
187
|
end
|
179
188
|
|