Skip to content

Commit 8f515f7

Browse files
authored
Merge pull request #5 from 7tp8ckm95b/master
fix for issue #4
2 parents d8c1c16 + 520180f commit 8f515f7

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

generate_test_cases.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,10 @@ def pg_quote(s)
194194
end
195195

196196
with_proto('scalars { float_field: 123.456 }') do
197-
test_query('pgpb.test.ExampleMessage:scalars.float_field', ['123.456001'])
197+
test_query('pgpb.test.ExampleMessage:scalars.float_field', ['123.456'])
198198
end
199199
with_proto('scalars { double_field: 123.456 }') do
200-
test_query('pgpb.test.ExampleMessage:scalars.double_field', ['123.456000'])
200+
test_query('pgpb.test.ExampleMessage:scalars.double_field', ['123.456'])
201201
end
202202

203203
with_proto('scalars { bool_field: true }') do

querying.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
extern "C" {
2828
// Must be included before other Postgres headers
2929
#include <postgres.h>
30+
#include <common/shortest_dec.h>
3031
}
3132

3233
namespace pb = ::google::protobuf;
@@ -463,10 +464,16 @@ class PrimitiveEmitter : public Emitter {
463464
field.wire_type, ty_);
464465
switch (ty_) {
465466
case T::TYPE_DOUBLE:
466-
Emit(WFL::DecodeDouble(field.value.as_uint64));
467+
{
468+
char *cstr = double_to_shortest_decimal(WFL::DecodeDouble(field.value.as_uint64));
469+
EmitStr(std::move(std::string(cstr)));
470+
}
467471
break;
468472
case T::TYPE_FLOAT:
469-
Emit(WFL::DecodeFloat(field.value.as_uint32));
473+
{
474+
char *cstr = float_to_shortest_decimal(WFL::DecodeFloat(field.value.as_uint32));
475+
EmitStr(std::move(std::string(cstr)));
476+
}
470477
break;
471478
case T::TYPE_INT64:
472479
case T::TYPE_SFIXED64:

0 commit comments

Comments
 (0)