Skip to content

Commit

Permalink
Merge pull request #73 from wey-gu/escape_new_line_ng_load
Browse files Browse the repository at this point in the history
feat: escape newline for ng_load
  • Loading branch information
wey-gu authored Aug 16, 2024
2 parents 41dc190 + 247a069 commit 17d8a96
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions ngql/ng_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,11 @@ def safe_load_file(source, file_type, header_option=None, limit=None):
)
prop_str += "NULL, "
elif prop_schema_map[prop_name]["type"] == "string":
raw_prop_str = prop_value.strip('"').replace('"', '\\"')
raw_prop_str = (
prop_value.strip('"')
.replace('"', '\\"')
.replace("\n", "\\n")
)
prop_str += f"{QUOTE}{raw_prop_str}{QUOTE}, "
elif prop_schema_map[prop_name]["type"] == "date":
prop_str += f"date({QUOTE}{prop_value}{QUOTE}), "
Expand Down Expand Up @@ -346,7 +350,11 @@ def safe_load_file(source, file_type, header_option=None, limit=None):
)
prop_str += "NULL, "
elif prop_schema_map[prop_name]["type"] == "string":
raw_prop_str = prop_value.strip('"').replace('"', '\\"')
raw_prop_str = (
prop_value.strip('"')
.replace('"', '\\"')
.replace("\n", "\\n")
)
prop_str += f"{QUOTE}{raw_prop_str}{QUOTE}, "
elif prop_schema_map[prop_name]["type"] == "date":
prop_str += f"date({QUOTE}{prop_value}{QUOTE}), "
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="jupyter_nebulagraph",
version="0.14.1",
version="0.14.2",
author="Wey Gu",
author_email="[email protected]",
description="Jupyter extension for NebulaGraph",
Expand Down
2 changes: 1 addition & 1 deletion setup_ipython.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="ipython-ngql",
version="0.14.1",
version="0.14.2",
author="Wey Gu",
author_email="[email protected]",
description="Jupyter extension for NebulaGraph",
Expand Down

0 comments on commit 17d8a96

Please sign in to comment.