From: kou@... Date: 2019-06-30T20:58:57+00:00 Subject: [ruby-core:93442] [Ruby master Bug#15967] Two dimensional array which have CSV::Row object returns different result in ruby 2.3 and ruby 2.6 Issue #15967 has been updated by kou (Kouhei Sutou). Assignee set to kou (Kouhei Sutou) Status changed from Third Party's Issue to Rejected It's introduced by #10013. Adding `CSV::Row#to_ary` may be wrong. But I couldn't remove `CSV::Row#to_ary` to avoid compatibility breakage again. ---------------------------------------- Bug #15967: Two dimensional array which have CSV::Row object returns different result in ruby 2.3 and ruby 2.6 https://bugs.ruby-lang.org/issues/15967#change-78988 * Author: kota0919wasabi (Kota Osabe) * Status: Rejected * Priority: Normal * Assignee: kou (Kouhei Sutou) * Target version: * ruby -v: 2.6.0rc1 * Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN ---------------------------------------- I posted this issue at stackoverlow below. https://stackoverflow.com/questions/56821461/two-dimensional-array-which-have-csvrow-object-returns-different-result-in-rub?noredirect=1#comment100198376_56821461 Two dimensional array has the element which is CSV::Row object like this. [[csv_row_object]] I tried to flatten this array and got different result in ruby 2.3 and 2.6. In the case of Ruby 2.3.8 ``` [1] pry(main)> RUBY_VERSION => "2.3.8" [2] pry(main)> filepath = "/Users/kota/Desktop/test.csv" => "/Users/kota/Desktop/test.csv" [3] pry(main)> data = fixture_file_upload(filepath, "text/csv") => #> [4] pry(main)> require 'csv' => true [5] pry(main)> parsed_csv = CSV.parse(data.read, headers:true, converters: nil) => # [6] pry(main)> parsed_csv[0] => # [7] pry(main)> parsed_csv[1] => # [8] pry(main)> parsed_csv[2] => # [9] pry(main)> array = [[parsed_csv[0]],[parsed_csv[1]],[parsed_csv[2]]] => [[#], [#], [#]] [10] pry(main)> array.flatten => [#, #, #] ``` In the case of Ruby 2.6 ``` [1] pry(main)> RUBY_VERSION => "2.6.0" [2] pry(main)> filepath = "/Users/kota/Desktop/test.csv" => "/Users/kota/Desktop/test.csv" [3] pry(main)> data = fixture_file_upload(filepath, "text/csv") => #> [4] pry(main)> require 'csv' => true [5] pry(main)> parsed_csv = CSV.parse(data.read, headers:true, converters: nil) => # [6] pry(main)> parsed_csv[0] => # [7] pry(main)> parsed_csv[1] => # [8] pry(main)> parsed_csv[2] => # [9] pry(main)> array = [[parsed_csv[0]],[parsed_csv[1]],[parsed_csv[2]]] => [[#], [#], [#]] [10] pry(main)> array.flatten => ["order_no", "10", "status", "1", "order_no", "20", "status", "1", "order_no", "30", "status", "1"] ``` -- https://bugs.ruby-lang.org/ Unsubscribe: