[ https://issues.apache.org/jira/browse/NIFI-4759?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16323893#comment-16323893 ]
ASF GitHub Bot commented on NIFI-4759: -------------------------------------- Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2392#discussion_r161212008 --- Diff: nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/PutMongo.java --- @@ -173,13 +166,25 @@ public void process(final InputStream in) throws IOException { // update final boolean upsert = context.getProperty(UPSERT).asBoolean(); final String updateKey = context.getProperty(UPDATE_QUERY_KEY).getValue(); - final Document query = new Document(updateKey, ((Map)doc).get(updateKey)); + final Document query; + + Object keyVal = ((Map)doc).get(updateKey); + if (updateKey.equals("_id")) { + try { + keyVal = new ObjectId((String) keyVal); + } catch (Exception ex) { + getLogger().error("{} is not a valid ObjectID, using raw value.", new Object[]{keyVal}); --- End diff -- That's the general pattern that is used in other places for building log statements. > PutMongo does not handle updateKey field correctly > -------------------------------------------------- > > Key: NIFI-4759 > URL: https://issues.apache.org/jira/browse/NIFI-4759 > Project: Apache NiFi > Issue Type: Bug > Reporter: Mike Thomsen > Assignee: Mike Thomsen > > Two issues: > * The updateKey field is ignored in favor of _id in the update code block of > PutMongo. > * _id fields are always treated as strings, even if they're valid ObjectIds > represented as a string. PutMongo should be able to handle these as ObjectIds. > Regarding the first point, this works: > {code:java} > { > "_id": "1234", > "$set": { "msg": "Hello, world" } > } > {code} > This does not: > {code:java} > { > "uniqueKey": "12345", > "$set": { "msg": "Hello, World" } > } > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)