Encoding map objects to string during escaping process#13
Open
michael-borisov wants to merge 3 commits intoplausible:masterfrom
Open
Encoding map objects to string during escaping process#13michael-borisov wants to merge 3 commits intoplausible:masterfrom
michael-borisov wants to merge 3 commits intoplausible:masterfrom
Conversation
ruslandoga
reviewed
Nov 22, 2022
| end | ||
|
|
||
| defp escape(s) when is_map(s) do | ||
| m = Jason.encode!(s) |
There was a problem hiding this comment.
can it be Jason.encode_to_iodata!/1?
Author
There was a problem hiding this comment.
Yes! Thank you for the suggestion!
There was a problem hiding this comment.
Wouldn't JSON iodata still need to be escaped?
With the current implementation I'm getting
Code: 62. DB::Exception: Cannot parse expression of type Object('json') here: '{\"should\":{\"'\":\"%\",\"\\\\\":\"\",\"_\":\"?\",\"it be\":\"escaped?\"}}'
for a map like
%{"should" => %{"it be" => "escaped?", "_" => "?", "'" => "%", "\\" => ""}}There was a problem hiding this comment.
Sorry for the confusion. I think the previous approach with Jason.encode! is the way to go since escaping iodata seems like too much work.
ruslandoga
approved these changes
Nov 22, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Encoding of incoming data in map format to JSON to prevent an error like those below
It happened when I tried to save data in the JSON field. The Clickhouse supports that as an experimental feature (https://clickhouse.com/docs/en/sql-reference/data-types/json/).