Skip to content

Commit

Permalink
V2 Output: Ignore null values for long and char fields too.
Browse files Browse the repository at this point in the history
  • Loading branch information
lfittl committed Dec 26, 2015
1 parent e84dba2 commit bfda212
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pg_query_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@

/* Write a long-integer field */
#define WRITE_LONG_FIELD(fldname) \
appendStringInfo(str, "\"" CppAsString(fldname) "\": %ld, ", node->fldname)
if (node->fldname != 0) { \
appendStringInfo(str, "\"" CppAsString(fldname) "\": %ld, ", node->fldname); \
}

/* Write a char field (ie, one ascii character) */
#define WRITE_CHAR_FIELD(fldname) \
if (node->fldname == 0) { appendStringInfo(str, "\"" CppAsString(fldname) "\": null, "); \
} else { appendStringInfo(str, "\"" CppAsString(fldname) "\": \"%c\", ", node->fldname); }
if (node->fldname != 0) { \
appendStringInfo(str, "\"" CppAsString(fldname) "\": \"%c\", ", node->fldname); \
}

/* Write an enumerated-type field as an integer code */
#define WRITE_ENUM_FIELD(fldname, enumtype) \
Expand Down

0 comments on commit bfda212

Please sign in to comment.