From 02ea1d97657ed81797e02ef80c7f89195cf82a27 Mon Sep 17 00:00:00 2001 From: Miloslav Trmač Date: Sat, 11 Aug 2012 09:52:53 +0200 Subject: Add support for optional JSON fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These fields are only relevant in field templates (i.e. mongodb): a field for a non-existent CEE property is not created (instead of being set to an empty string). Signed-off-by: Miloslav Trmač --- runtime/msg.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'runtime') diff --git a/runtime/msg.c b/runtime/msg.c index 0d01f5e1..0ee78ae0 100644 --- a/runtime/msg.c +++ b/runtime/msg.c @@ -3500,6 +3500,14 @@ rsRetVal MsgAppendFields(msg_t *pMsg, struct templateEntry *pTpe, } } } else { + /* FIXME: this performs a duplicate lookup, which wastes + time. */ + if(pTpe->data.field.options.bOptionalField + && (pMsg->event == NULL + || ee_getEventField(pMsg->event, + pTpe->data.field.propName) == NULL)) + FINALIZE; /* Nothing to do */ + CHKiRet(FBSensureSpace(state)); dst = state->fields + state->nextField; -- cgit