mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
Remove FormatSettings default value for writeJSONString and add tests for output_format_json_escape_forward_slashes.
This commit is contained in:
parent
4e7b2927dd
commit
e8d4654419
@ -95,13 +95,14 @@ void FileChecker::save() const
|
||||
/// So complex JSON structure - for compatibility with the old format.
|
||||
writeCString("{\"yandex\":{", out);
|
||||
|
||||
auto settings = FormatSettings();
|
||||
for (auto it = map.begin(); it != map.end(); ++it)
|
||||
{
|
||||
if (it != map.begin())
|
||||
writeString(",", out);
|
||||
|
||||
/// `escapeForFileName` is not really needed. But it is left for compatibility with the old code.
|
||||
writeJSONString(escapeForFileName(it->first), out);
|
||||
writeJSONString(escapeForFileName(it->first), out, settings);
|
||||
writeString(":{\"size\":\"", out);
|
||||
writeIntText(it->second, out);
|
||||
writeString("\"}", out);
|
||||
|
@ -50,7 +50,7 @@ void JSONRowOutputStream::writePrefix()
|
||||
writeString(fields[i].name, *ostr);
|
||||
writeCString(",\n", *ostr);
|
||||
writeCString("\t\t\t\"type\": ", *ostr);
|
||||
writeJSONString(fields[i].type->getName(), *ostr);
|
||||
writeJSONString(fields[i].type->getName(), *ostr, settings);
|
||||
writeChar('\n', *ostr);
|
||||
|
||||
writeCString("\t\t}", *ostr);
|
||||
@ -149,7 +149,7 @@ void JSONRowOutputStream::writeTotals()
|
||||
writeCString(",\n", *ostr);
|
||||
|
||||
writeCString("\t\t", *ostr);
|
||||
writeJSONString(column.name, *ostr);
|
||||
writeJSONString(column.name, *ostr, settings);
|
||||
writeCString(": ", *ostr);
|
||||
column.type->serializeTextJSON(*column.column.get(), 0, *ostr, settings);
|
||||
}
|
||||
|
@ -174,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, const FormatSettings & settings = FormatSettings())
|
||||
inline void writeJSONString(const char * begin, const char * end, WriteBuffer & buf, const FormatSettings & settings)
|
||||
{
|
||||
writeChar('"', buf);
|
||||
for (const char * it = begin; it != end; ++it)
|
||||
@ -313,13 +313,13 @@ void writeAnyEscapedString(const char * begin, const char * end, WriteBuffer & b
|
||||
}
|
||||
|
||||
|
||||
inline void writeJSONString(const String & s, WriteBuffer & buf, const FormatSettings & settings = FormatSettings())
|
||||
inline void writeJSONString(const String & s, WriteBuffer & buf, const FormatSettings & settings)
|
||||
{
|
||||
writeJSONString(s.data(), s.data() + s.size(), buf, settings);
|
||||
}
|
||||
|
||||
|
||||
inline void writeJSONString(const StringRef & ref, WriteBuffer & buf, const FormatSettings & settings = FormatSettings())
|
||||
inline void writeJSONString(const StringRef & ref, WriteBuffer & buf, const FormatSettings & settings)
|
||||
{
|
||||
writeJSONString(ref.data, ref.data + ref.size, buf, settings);
|
||||
}
|
||||
|
@ -0,0 +1,2 @@
|
||||
{"url":"\/some\/cool\/url"}
|
||||
{"url":"/some/cool/url"}
|
@ -0,0 +1,5 @@
|
||||
SET output_format_json_escape_forward_slashes = 1;
|
||||
select '/some/cool/url' as url format JSONEachRow;
|
||||
SET output_format_json_escape_forward_slashes = 0;
|
||||
select '/some/cool/url' as url format JSONEachRow;
|
||||
SET output_format_json_escape_forward_slashes = 1;
|
Loading…
Reference in New Issue
Block a user