From 7669dc219675e81d38736c3cf0b0e8cef699a37c Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Sat, 2 May 2020 07:12:25 +0900 Subject: [PATCH] Support `limit(n)` and `offset(n)` nodes in dot output --- activerecord/lib/arel/visitors/dot.rb | 2 +- activerecord/test/cases/arel/visitors/dot_test.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/activerecord/lib/arel/visitors/dot.rb b/activerecord/lib/arel/visitors/dot.rb index 25cd564fcc..4a4da66f38 100644 --- a/activerecord/lib/arel/visitors/dot.rb +++ b/activerecord/lib/arel/visitors/dot.rb @@ -222,7 +222,7 @@ module Arel # :nodoc: all edge("value") { visit o.value } end - def visit_ActiveRecord_Relation_QueryAttribute(o) + def visit_ActiveModel_Attribute(o) edge("value_before_type_cast") { visit o.value_before_type_cast } end diff --git a/activerecord/test/cases/arel/visitors/dot_test.rb b/activerecord/test/cases/arel/visitors/dot_test.rb index ade53c358e..be9f176be9 100644 --- a/activerecord/test/cases/arel/visitors/dot_test.rb +++ b/activerecord/test/cases/arel/visitors/dot_test.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require_relative "../helper" +require "active_model/attribute" module Arel module Visitors @@ -78,6 +79,12 @@ module Arel collector = Collectors::PlainString.new assert_match '[label="Arel::Nodes::BindParam"]', @visitor.accept(node, collector).value end + + def test_ActiveModel_Attribute + node = ActiveModel::Attribute.with_cast_value("LIMIT", 1, nil) + collector = Collectors::PlainString.new + assert_match '[label="ActiveModel::Attribute::WithCastValue"]', @visitor.accept(node, collector).value + end end end end