Return NULL from json_object_agg if it gets no rows.
authorAndrew Dunstan
Thu, 25 Sep 2014 12:18:18 +0000 (08:18 -0400)
committerAndrew Dunstan
Thu, 25 Sep 2014 12:19:44 +0000 (08:19 -0400)
This makes it consistent with the docs and with all other builtin
aggregates apart from count().

src/backend/utils/adt/json.c

index 494a0285267a542582c8129a40fe551e2128cdb2..1820029fe956d68d28678826dfc0d33097245660 100644 (file)
@@ -1973,7 +1973,7 @@ json_object_agg_finalfn(PG_FUNCTION_ARGS)
    state = PG_ARGISNULL(0) ? NULL : (StringInfo) PG_GETARG_POINTER(0);
 
    if (state == NULL)
-       PG_RETURN_TEXT_P(cstring_to_text("{}"));
+       PG_RETURN_NULL();
 
    appendStringInfoString(state, " }");