From be7ce739e24d1ce320fbccd3fb58ad557ddfe67b Mon Sep 17 00:00:00 2001 From: James Silberbauer Date: Wed, 5 Oct 2016 18:41:27 +0200 Subject: [PATCH] Deparse Float. --- lib/pg_query/deparse.rb | 2 ++ spec/lib/pg_query/deparse_spec.rb | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/lib/pg_query/deparse.rb b/lib/pg_query/deparse.rb index 0fcfbfa7..b30a4715 100644 --- a/lib/pg_query/deparse.rb +++ b/lib/pg_query/deparse.rb @@ -150,6 +150,8 @@ def deparse_item(item, context = nil) # rubocop:disable Metrics/CyclomaticComple end when INTEGER node['ival'].to_s + when FLOAT + node['str'] else fail format("Can't deparse: %s: %s", type, node.inspect) end diff --git a/spec/lib/pg_query/deparse_spec.rb b/spec/lib/pg_query/deparse_spec.rb index 1f7db3a1..071331b5 100644 --- a/spec/lib/pg_query/deparse_spec.rb +++ b/spec/lib/pg_query/deparse_spec.rb @@ -221,6 +221,11 @@ let(:query) { 'SELECT * FROM "x" OFFSET 50' } it { is_expected.to eq query } end + + context 'FLOAT' do + let(:query) { 'SELECT "amount" * 0.5' } + it { is_expected.to eq query } + end end context 'type cast' do