-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make avro serde accept clj maps with underscores, add option to skip mangling names. #126
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be a useful change. If I had our time again, *mangle-names* == false
would be the default but I think the ship has sailed on that.
@creese do you accept this in principle? If so, we might consider adding it as an option here
jackdaw/src/jackdaw/serdes/avro.clj
Line 607 in 6307689
key?] |
test/jackdaw/serdes/avro_test.clj
Outdated
schema-str (json/write-str schema) | ||
serde (->serde schema-str)] | ||
|
||
(is (= (round-trip serde "bananas" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It took me a while before I realized that the difference between the 1st and 2nd round-trip tests here was that the enum field was expressed as a string in the first, and a keyword in the second. Would you mind putting each one inside a testing
block so that they can more easily be distinguished?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I have restructured the tests and added documentation to make them more readable.
I used a dynamic var for *mangle-names*
as it made more sense for me to have it as an 'application-level configuration'. It will lead to a consistent low level design within an application - either use idiomised values or not. (although, I agree the degree of ambiguity wouldn't be much as there will always be a default setting).
I noticed that the mangling is done only for the serde and not for json etc., So, as you mentioned, it would make sense to drop it altogether and push the responsibility to the apps if they need such a feature. The dynamic var will be a nice way to provide backward compatibility during transition if you decide to drop mangling in a future release.
Let me know your thoughts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codecov Report
@@ Coverage Diff @@
## master #126 +/- ##
=========================================
Coverage ? 80.86%
=========================================
Files ? 39
Lines ? 2315
Branches ? 147
=========================================
Hits ? 1872
Misses ? 296
Partials ? 147
Continue to review full report at Codecov.
|
Anything blocking this from being merged? |
Can this be merged? This caused us issues as well as the data mangling was a surprise to us |
+1 for merging this. Not be able to use maps with snake_case is a bit of a showstopper. |
Ive made a quick fix/change to the avro serde to make it accept non-idiomatic, but perfectly valid maps as input. For eg.
I also added an option to skip mangling names like in the abracad library. This will be useful when we need to use the original message.