Skip to content
This repository has been archived by the owner on May 31, 2023. It is now read-only.

fixed #14 respect negative numbers #15

Merged
merged 2 commits into from
Jan 3, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/pg_numhstore.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ HStore * hstoreUpgrade( Datum orig )
size_t adeven_get_digit_num( long number )
{
size_t count = 0;
if( number == 0 )
return 1;
if( number == 0 || number < 0 )
++count;
while( number != 0 )
{
number /= 10;
Expand Down
6 changes: 6 additions & 0 deletions test/expected/numhstore_c_func_tests.out
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,9 @@ SELECT array_add(ARRAY['foo','bar','foo'],ARRAY[2E9::integer,2E9::integer,2E9::i
"bar"=>"2000000000", "foo"=>"4000000000"
(1 row)

SELECT array_add(Array['foo','bar','foo'], Array[2,3,-5]);
array_add
-------------------------
"bar"=>"3", "foo"=>"-3"
(1 row)

1 change: 1 addition & 0 deletions test/sql/numhstore_c_func_tests.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ SELECT array_add(ARRAY['foo','bar','baz'],ARRAY[1,2]);
SELECT array_add(ARRAY['foo','foo','bar','foo'],ARRAY[2,NULL,2,2]);
SELECT array_add(ARRAY['foo',NULL,'foo','bar'],ARRAY[2,2,2,2]);
SELECT array_add(ARRAY['foo','bar','foo'],ARRAY[2E9::integer,2E9::integer,2E9::integer]);
SELECT array_add(Array['foo','bar','foo'], Array[2,3,-5]);