From: Dmitry Simushev Date: Sat, 28 Dec 2019 13:38:05 +0000 (+0300) Subject: Fix empty arrays parsing X-Git-Tag: v2.1.6~2^2 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=843fc4cf789fa12ef08e6beefc4653498fe73bfd;p=m6w6%2Fext-pq Fix empty arrays parsing --- diff --git a/src/php_pq_misc.c b/src/php_pq_misc.c index df07591..619559d 100644 --- a/src/php_pq_misc.c +++ b/src/php_pq_misc.c @@ -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; diff --git a/tests/types002.phpt b/tests/types002.phpt index e2d772d..9d36788 100644 --- a/tests/types002.phpt +++ b/tests/types002.phpt @@ -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