-
Enhancement
-
Resolution: Done
-
Optional
-
None
-
None
-
False
-
None
-
False
See Zulip discussion at https://debezium.zulipchat.com/#narrow/stream/348106-community-mongodb/topic/Raw.20string.20manipulation.20during.20extraction.20of.20document.20keys
The code in the lines at https://github.com/debezium/debezium/blob/main/debezium-connector-mongodb/src/main/java/io/debezium/connector/mongodb/JsonSerialization.java#L60-L66 seems at first to be a little convoluted – in order to get an id out of the document argument, it first extracts the id, then re-nests the id in a new document with a fieldname of fixed length, then serializes that, then extracts the id again, this time using raw string manipulation.
This seems odd but there's a good reason for it: it's tough to serialize scalar bson values and this is a good workaround, see the Zulip discussion above.
Although necessary, this code is a little brittle and has possibly been involved in errors such as the one described in DBZ-7157.
If we explain it a little more in a comment, these errors might be less likely to happen.
I'm just going to fix up the comment and make a PR.
- links to
-
RHEA-2024:139598 Red Hat build of Debezium 2.5.4 release