Skip to content
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

Add output_format_json_escape_slashes setting - controls escaping sla… #2812

Conversation

bocharov
Copy link
Contributor

@bocharov bocharov commented Aug 6, 2018

Add output_format_json_escape_slashes setting - controls escaping slashes for string outputs in JSON output format.

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

@@ -176,7 +176,7 @@ static void writeExtremesElement(const char * title, const Block & extremes, siz
writeCString(",\n", ostr);

writeCString("\t\t\t", ostr);
writeJSONString(column.name, ostr);
writeJSONString(column.name, ostr, settings);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

settings are propagated not in every call to writeJSONString.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexey-milovidov please have another look, should be fine now.
Also added some basic tests.

@@ -173,7 +174,7 @@ inline void writeString(const StringRef & ref, WriteBuffer & buf)
* - it is assumed that string is in UTF-8, the invalid UTF-8 is not processed
* - all other non-ASCII characters remain as is
*/
inline void writeJSONString(const char * begin, const char * end, WriteBuffer & buf)
inline void writeJSONString(const char * begin, const char * end, WriteBuffer & buf, const FormatSettings & settings = FormatSettings())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to remove default whenever possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in every place the settings are available, e.g. FileChecker::save method doesn't have settings instance available.
How should we approach this case?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just create default FormatSettings before call to this function.
If the function is called in the loop - move FormatSettings out of the loop, just in case.

Copy link
Member

@alexey-milovidov alexey-milovidov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

@alexey-milovidov alexey-milovidov merged commit b1d70c1 into ClickHouse:master Aug 7, 2018
@bocharov bocharov deleted the feature-add-output_format_json_escape_slashes-setting branch August 11, 2018 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants