[#62904] [ruby-trunk - Feature #9894] [Open] [RFC] README.EXT: document rb_gc_register_mark_object — normalperson@...
Issue #9894 has been reported by Eric Wong.
3 messages
2014/06/02
[#63321] [ANN] ElixirConf 2014 - Don't Miss Jos辿 Valim and Dave Thomas — Jim Freeze <jimfreeze@...>
Just a few more weeks until ElixirConf 2014!
6 messages
2014/06/24
[ruby-core:63375] [ruby-trunk - Bug #9988] [Open] CSV does not write headers when :write_headers is true and no rows are added
From:
merch-redmine@...
Date:
2014-06-27 17:39:42 UTC
List:
ruby-core #63375
Issue #9988 has been reported by Jeremy Evans.
----------------------------------------
Bug #9988: CSV does not write headers when :write_headers is true and no rows are added
https://bugs.ruby-lang.org/issues/9988
* Author: Jeremy Evans
* Status: Open
* Priority: Normal
* Assignee: James Gray
* Category: lib
* Target version:
* ruby -v: ruby -v: ruby 2.1.2p95 (2014-05-08 revision 45877) [i386-openbsd]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
When the CSV :write_headers option is used, headers are only added if at least one row is added:
~~~
$ ruby -r csv -e "p CSV.generate(:headers=>%w'a b c', :write_headers=>true){|csv|}"
""
$ ruby -r csv -e "p CSV.generate(:headers=>%w'a b c', :write_headers=>true){|csv| csv << []}"
"a,b,c\n\n"
~~~
This seems like a bug to me. It should write the headers even if there are no rows. The attached patch does that:
~~~
$ ruby -I lib -r csv -e "p CSV.generate(:headers=>%w'a b c', :write_headers=>true){|csv|}"
"a,b,c\n"
~~~
The attached patch should probably be refactored to avoid the duplication, but I think that is best left to the csv maintainer.
---Files--------------------------------
csv-write-headers-empty-fix.diff (1.47 KB)
--
https://bugs.ruby-lang.org/