-
Notifications
You must be signed in to change notification settings - Fork 45
feat: avro schema add sanitize field name #190
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
base: main
Are you sure you want to change the base?
feat: avro schema add sanitize field name #190
Conversation
Please add test cases. Thanks! |
Ok |
@wgtmac Hi, cpp-linter report an error, maybe I forgot to open an issue cause it. Can you retry it? Thanks!
|
8339497
to
51f205c
Compare
Let me know when it is ready to review. Thanks! |
You can review thanks |
@wgtmac You can review thanks |
/// | ||
/// \param name The name to check. | ||
/// \return True if the name is valid, false otherwise. | ||
bool ValidAvroName(const std::string& name); |
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.
bool ValidAvroName(const std::string& name); | |
bool ValidAvroName(std::string_view name); |
std::string_view
accepts wider types than std::string
std::string origFieldName = std::string(sub_field.name()); | ||
bool isValidFieldName = ValidAvroName(origFieldName); | ||
std::string fieldName = | ||
isValidFieldName ? origFieldName : SanitizeFieldName(origFieldName); |
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.
std::string origFieldName = std::string(sub_field.name()); | |
bool isValidFieldName = ValidAvroName(origFieldName); | |
std::string fieldName = | |
isValidFieldName ? origFieldName : SanitizeFieldName(origFieldName); | |
bool is_valid_field_name = ValidAvroName(sub_field.name()); | |
std::string field_name = | |
is_valid_field_name ? std::string(sub_field.name()) : SanitizeFieldName(sub_field.name()); |
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.
We don't want to pay for a copy when it is a valid name.
avro schema add sanitize field name issue #192