diff --git a/lib/liquid/standardfilters.rb b/lib/liquid/standardfilters.rb index 1864742e..3bbee4a5 100644 --- a/lib/liquid/standardfilters.rb +++ b/lib/liquid/standardfilters.rb @@ -979,6 +979,7 @@ module Liquid def filter_array(input, property, target_value, default_value = [], &block) ary = InputIterator.new(input, context) + return default_value if ary.empty? property = Utils.to_s(property) diff --git a/test/integration/standard_filter_test.rb b/test/integration/standard_filter_test.rb index 6a2737bb..62ec5d2d 100644 --- a/test/integration/standard_filter_test.rb +++ b/test/integration/standard_filter_test.rb @@ -1109,19 +1109,6 @@ class StandardFiltersTest < Minitest::Test assert_template_result(expected_output, template, { "array" => array }) end - def test_where_with_non_string_property - array = [ - { "handle" => "alpha", "{}" => true }, - { "handle" => "beta", "{}" => false }, - { "handle" => "gamma", "{}" => false }, - { "handle" => "delta", "{}" => true }, - ] - template = "{{ array | where: some_property, true | map: 'handle' | join: ' ' }}" - expected_output = "alpha delta" - - assert_template_result(expected_output, template, { "array" => array, "some_property" => {} }) - end - def test_where_string_keys input = [ "alpha", "beta", "gamma", "delta"