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

Remove double quotes from filenames #22

Merged
merged 2 commits into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pgtricks/pg_split_schema_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def split_sql_file(sqlpath: str, target_directory: str) -> None:
)
print(part)
continue
name = match.group(1).replace(" ", "_")
name = match.group(1).replace(" ", "_").replace('"', "")
type_ = match.group(2).replace(" ", "_")
schema = match.group(3)
if schema == "-":
Expand Down
35 changes: 35 additions & 0 deletions pgtricks/tests/test_pg_split_schema_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,38 @@ def test_split_sql_file_unrecognized_content(tmpdir):
(information for the unidentified content goes here)
============================================================================="""
)


def test_split_sql_file_with_quotes_in_name(tmpdir):
target_directory = tmpdir / "target"
sqlpath = tmpdir / "test.sql"
sqlpath.write(
dedent(
"""

--
-- Name: "user"; Type: TABLE; Schema: public; Owner:
--

(information for user table goes here)
"""
)
)

split_sql_file(str(sqlpath), str(target_directory))

assert {path.basename for path in target_directory.listdir()} == {
"public.user.TABLE"
}
assert (target_directory / "public.user.TABLE").readlines(cr=False) == [
"SET search_path = public;",
"",
"",
"",
"--",
'-- Name: "user"; Type: TABLE; Schema: public; Owner:',
"--",
"",
"(information for user table goes here)",
"",
]
Loading