Fix empty arrays parsing 34/head
authorDmitry Simushev <simushevds@gmail.com>
Sat, 28 Dec 2019 13:38:05 +0000 (16:38 +0300)
committerDmitry Simushev <simushevds@gmail.com>
Sat, 28 Dec 2019 13:46:04 +0000 (16:46 +0300)
src/php_pq_misc.c
tests/types002.phpt

index df07591570153603be6137d5ec62634abc15ecda..619559d0fe724d393d299b72b467c0b84cd5a673 100644 (file)
@@ -318,6 +318,9 @@ static ZEND_RESULT_CODE parse_element(ArrayParserState *a, char delim)
        case '{':
                return parse_array(a);
 
+       case '}':
+               return SUCCESS;
+
        case '"':
                a->quotes = 1;
                ++a->ptr;
index e2d772d29393b8bbb17d5a90cabb3b05e8a287c2..9d36788706311b8a414e5d3f8de8b2fca0288071 100644 (file)
@@ -25,14 +25,15 @@ true as bool,
 '2013-01-01 01:01:01'::timestamp as timestamp,
 '2013-01-01 01:01:01 UTC'::timestamptz as timestamptz,
 array[array[1,2,3],array[4,5,6],array[NULL::int,NULL::int,NULL::int]] as intarray,
-array[box(point(1,2),point(2,3)),box(point(4,5),point(5,6))] as boxarray
+array[box(point(1,2),point(2,3)),box(point(4,5),point(5,6))] as boxarray,
+array[]::text[] as emptyarray
 ");
 var_dump($r->fetchRow(pq\Result::FETCH_ASSOC));
 ?>
 DONE
 --EXPECTF--
 Test
-array(12) {
+array(13) {
   ["null"]=>
   NULL
   ["bool"]=>
@@ -117,5 +118,8 @@ array(12) {
     [1]=>
     string(11) "(5,6),(4,5)"
   }
+  ["emptyarray"]=>
+  array(0) {
+  }
 }
 DONE
\ No newline at end of file