From 6d1c96e445bd0c79dcc9a059b86414925757f174 Mon Sep 17 00:00:00 2001 From: Daniel Nichter Date: Mon, 18 Feb 2013 12:51:28 -0700 Subject: [PATCH] Seralize empty list as undef. --- lib/Quoter.pm | 2 +- t/lib/Quoter.t | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Quoter.pm b/lib/Quoter.pm index 9c530830..f41d431e 100644 --- a/lib/Quoter.pm +++ b/lib/Quoter.pm @@ -161,7 +161,7 @@ sub join_quote { sub serialize_list { my ( $self, @args ) = @_; PTDEBUG && _d('Serializing', Dumper(\@args)); - die "Cannot serialize an empty array" unless scalar @args; + return unless @args; my @parts; foreach my $arg ( @args ) { diff --git a/t/lib/Quoter.t b/t/lib/Quoter.t index a7bbf794..34e9fb52 100644 --- a/t/lib/Quoter.t +++ b/t/lib/Quoter.t @@ -125,6 +125,12 @@ is( $q->join_quote('`db`', '`foo`.`tbl`'), '`foo`.`tbl`', 'join_merge(`db`, `foo # ########################################################################### # (de)serialize_list # ########################################################################### + +is( + $q->serialize_list( () ), + undef, + 'Serialize empty list returns undef' +); binmode(STDOUT, ':utf8') or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR";