Skip to content

Fix virtual Postgres source_file URI backslash normalization on Windows (#1672)#1675

Open
raman118 wants to merge 1 commit into
Graphify-Labs:v8from
raman118:fix/1672-postgres-uri-backslashes
Open

Fix virtual Postgres source_file URI backslash normalization on Windows (#1672)#1675
raman118 wants to merge 1 commit into
Graphify-Labs:v8from
raman118:fix/1672-postgres-uri-backslashes

Conversation

@raman118

@raman118 raman118 commented Jul 4, 2026

Copy link
Copy Markdown

Summary

This PR resolves issue #1672, where introspect_postgres() produces invalid source_file URIs on Windows (e.g., postgresql:\myhost\mydb instead of postgresql:/myhost/mydb).

Cause

In graphify/pg_introspect.py, the virtual_path was constructed using pathlib.Path(f"postgresql://{host}/{dbname}"). On Windows, this instantiates a WindowsPath object, which normalizes the path separators to backslashes (\). Because the path is a synthetic URI rather than a local file path, it should be OS-independent and retain forward slashes.

Solution

  • Imported and utilized pathlib.PurePosixPath to construct virtual_path. Since PurePosixPath uses POSIX path semantics regardless of the host operating system, the path string uses forward slashes on all platforms.
  • Added the regression test test_pg_introspect_uri_forward_slashes in tests/test_pg_introspect.py to assert that the generated virtual paths always contain forward slashes and no backslashes, even when run on Windows.
  • Successfully verified that all postgresql introspection tests pass on Windows.
  • Executed graphify update . to rebuild the AST knowledge graph.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant