mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 01:22:04 +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.
|
/// So complex JSON structure - for compatibility with the old format.
|
||||||
writeCString("{\"yandex\":{", out);
|
writeCString("{\"yandex\":{", out);
|
||||||
|
|
||||||
|
auto settings = FormatSettings();
|
||||||
for (auto it = map.begin(); it != map.end(); ++it)
|
for (auto it = map.begin(); it != map.end(); ++it)
|
||||||
{
|
{
|
||||||
if (it != map.begin())
|
if (it != map.begin())
|
||||||
writeString(",", out);
|
writeString(",", out);
|
||||||
|
|
||||||
/// `escapeForFileName` is not really needed. But it is left for compatibility with the old code.
|
/// `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);
|
writeString(":{\"size\":\"", out);
|
||||||
writeIntText(it->second, out);
|
writeIntText(it->second, out);
|
||||||
writeString("\"}", out);
|
writeString("\"}", out);
|
||||||
|
@ -50,7 +50,7 @@ void JSONRowOutputStream::writePrefix()
|
|||||||
writeString(fields[i].name, *ostr);
|
writeString(fields[i].name, *ostr);
|
||||||
writeCString(",\n", *ostr);
|
writeCString(",\n", *ostr);
|
||||||
writeCString("\t\t\t\"type\": ", *ostr);
|
writeCString("\t\t\t\"type\": ", *ostr);
|
||||||
writeJSONString(fields[i].type->getName(), *ostr);
|
writeJSONString(fields[i].type->getName(), *ostr, settings);
|
||||||
writeChar('\n', *ostr);
|
writeChar('\n', *ostr);
|
||||||
|
|
||||||
writeCString("\t\t}", *ostr);
|
writeCString("\t\t}", *ostr);
|
||||||
@ -149,7 +149,7 @@ void JSONRowOutputStream::writeTotals()
|
|||||||
writeCString(",\n", *ostr);
|
writeCString(",\n", *ostr);
|
||||||
|
|
||||||
writeCString("\t\t", *ostr);
|
writeCString("\t\t", *ostr);
|
||||||
writeJSONString(column.name, *ostr);
|
writeJSONString(column.name, *ostr, settings);
|
||||||
writeCString(": ", *ostr);
|
writeCString(": ", *ostr);
|
||||||
column.type->serializeTextJSON(*column.column.get(), 0, *ostr, settings);
|
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
|
* - it is assumed that string is in UTF-8, the invalid UTF-8 is not processed
|
||||||
* - all other non-ASCII characters remain as is
|
* - 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);
|
writeChar('"', buf);
|
||||||
for (const char * it = begin; it != end; ++it)
|
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);
|
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);
|
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