Home  |  Linux  | Mysql  | PHP  | XML
From:turnstep@cvs.perl.org Date:Mon Aug 18 07:42:06 2008
Subject:[svn:DBD-Pg] r11661 - in DBD-Pg/trunk: . t
Author: turnstep
Date: Mon Aug 18 06:42:05 2008
New Revision: 11661

Modified:
   DBD-Pg/trunk/Changes
   DBD-Pg/trunk/dbdimp.c
   DBD-Pg/trunk/t/09arrays.t

Log:
Mapping empty Postgres arrays should give an empty Perl array, not an undef-filled one.
Thanks to David E. Wheeler for catching this.


Modified: DBD-Pg/trunk/Changes
==============================================================================
--- DBD-Pg/trunk/Changes	(original)
+++ DBD-Pg/trunk/Changes	Mon Aug 18 06:42:05 2008
@@ -1,6 +1,11 @@
 ('GSM' is Greg Sabino Mullane, greg@turnstep.com)
 
-2.9.1 Released August 17, 2008
+2.9.2 Released August 18, 2008
+
+	- Empty Postgres arrays should return empty Perl arrays, not undef.
+		(CPAN bug #38552) [David E. Wheeler]
+
+2.9.1 Released August 17, 2008 (subversion r11660)
 
 	- Return undef when mapping Postgres array to Perl array and 
 		the array is empty '{}'. (CPAN bug #38552) [GSM]

Modified: DBD-Pg/trunk/dbdimp.c
==============================================================================
--- DBD-Pg/trunk/dbdimp.c	(original)
+++ DBD-Pg/trunk/dbdimp.c	Mon Aug 18 06:42:05 2008
@@ -2531,8 +2531,10 @@
 
 		if ('}' == *input || (coltype->array_delimeter == *input && '}' != *(input-1))) {
 			string[section_size] = '\0';
-			if ((0 == section_size && !seen_quotes) || 
-				((4 == section_size && 0 == strncmp(string, "NULL", 4) && '"' != *(input-1)))) {
+			if (0 == section_size && !seen_quotes) {
+				/* Just an empty array */
+			}
+			else if (4 == section_size && 0 == strncmp(string, "NULL", 4) && '"' != *(input-1)) {
 				av_push(currentav, &PL_sv_undef);
 			}
 			else {

Modified: DBD-Pg/trunk/t/09arrays.t
==============================================================================
--- DBD-Pg/trunk/t/09arrays.t	(original)
+++ DBD-Pg/trunk/t/09arrays.t	Mon Aug 18 06:42:05 2008
@@ -296,12 +296,12 @@
 
 ## Test of no-item and empty string arrays
 
-$t=q{String array with no items returns undef};
+$t=q{String array with no items returns empty array};
 $cleararray->execute();
 $addarray->execute('{}');
 $getarray->execute();
 $result = $getarray->fetchall_arrayref();
-is_deeply ($result, [[[undef]]], $t);
+is_deeply ($result, [[[]]], $t);
 
 $t=q{String array with empty string returns empty string};
 $cleararray->execute();
@@ -310,12 +310,12 @@
 $result = $getarray->fetchall_arrayref();
 is_deeply ($result, [[['']]], $t);
 
-$t=q{Integer array with no items returns undef};
+$t=q{Integer array with no items returns empty array};
 $cleararray->execute();
 $addarray_int->execute('{}');
 $getarray_int->execute();
 $result = $getarray_int->fetchall_arrayref();
-is_deeply ($result, [[[undef]]], $t);
+is_deeply ($result, [[[]]], $t);
 
 ## Pure string to array conversion testing
 
Navigate in group perl.dbd.pg.changes at sever nntp.perl.org
Previous Next




  
© No Copyright
You are free to use Anything
Site Maintained by PHP Developer
Powered By PHP Consultants