From b7e91eff47d367e25351e20bc1cb660b1493f2f9 Mon Sep 17 00:00:00 2001 From: Adam Lassek Date: Fri, 26 Aug 2016 17:28:12 -0500 Subject: [PATCH 1/2] Add failing test for Dot visitor and BindParam Since BindParam has no value, treating it like a string causes it to fallback to Object#to_s, leading to output like `#`. Since angle brackets are significant in Dot labels, this causes `Error: bad label format` when passing the graph into dot. --- test/visitors/test_dot.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/visitors/test_dot.rb b/test/visitors/test_dot.rb index 4dc3c9c6c5..6db9b9b6de 100644 --- a/test/visitors/test_dot.rb +++ b/test/visitors/test_dot.rb @@ -70,6 +70,12 @@ module Arel @visitor.accept binary, Collectors::PlainString.new end end + + def test_Arel_Nodes_BindParam + node = Arel::Nodes::BindParam.new + collector = Collectors::PlainString.new + assert_match '[label="Arel::Nodes::BindParam"]', @visitor.accept(node, collector).value + end end end end From 63d180c96ff0096d417c6ddac56ec074a51e41a5 Mon Sep 17 00:00:00 2001 From: Adam Lassek Date: Fri, 26 Aug 2016 17:33:08 -0500 Subject: [PATCH 2/2] Change BindParam visit method for Dot to a noop Since BindParam contains no information, treating it like a string adds no useful information to the graph, and results in an invalid label format. --- lib/arel/visitors/dot.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/arel/visitors/dot.rb b/lib/arel/visitors/dot.rb index ca8d2b0bd0..31e4a66a1f 100644 --- a/lib/arel/visitors/dot.rb +++ b/lib/arel/visitors/dot.rb @@ -204,7 +204,6 @@ module Arel alias :visit_NilClass :visit_String alias :visit_TrueClass :visit_String alias :visit_FalseClass :visit_String - alias :visit_Arel_Nodes_BindParam :visit_String alias :visit_Integer :visit_String alias :visit_Fixnum :visit_String alias :visit_BigDecimal :visit_String @@ -212,6 +211,8 @@ module Arel alias :visit_Symbol :visit_String alias :visit_Arel_Nodes_SqlLiteral :visit_String + def visit_Arel_Nodes_BindParam o; end + def visit_Hash o o.each_with_index do |pair, i| edge("pair_#{i}") { visit pair }