Skip to content
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
11 changes: 8 additions & 3 deletions pgdevkit/testdb/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ def _get_sql_deps(sql: str) -> set[str]:
continue
for t in e.find_all(exp.Table):
if t.args.get("this") is not None and t.args.get("db") is not None:
deps.add(str(t))
# exp.table_name(), not str(t): str() includes " AS alias" for
# an aliased reference (e.g. "FROM editing.visit v"), which
# would never match the plain declared name any dependent
# file's own CREATE target is recorded under.
deps.add(exp.table_name(t))
return deps


Expand All @@ -119,7 +123,7 @@ def _iter_sql_files(database_dir: Path):
deps = _get_sql_deps(content)
if file.parent.name in _SCHEMA_QUALIFIED_TYPES:
schema = _strip_layer_prefix(file.parent.parent.name)
full_name = f"{schema}.{file.stem}"
full_name = f"{schema}.{_strip_layer_prefix(file.stem)}"
deps.discard(full_name) # the file's own CREATE target is not a real dependency
all_declared.add(full_name)
if not deps or all(d in delivered for d in deps):
Expand Down Expand Up @@ -219,7 +223,8 @@ async def _apply(file: Path, sql: str) -> None:
json_file = file.with_suffix(".test_data.json")
if json_file.exists():
schema_name = _strip_layer_prefix(file.parent.parent.name)
await _insert_test_data(json_file, f"{schema_name}.{file.stem}", force_reset, con, complex_helper)
table_stem = _strip_layer_prefix(file.stem)
await _insert_test_data(json_file, f"{schema_name}.{table_stem}", force_reset, con, complex_helper)

failures: list[tuple[Path, str]] = []
for file, sql in _iter_sql_files(database_dir):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ packages = ["pgdevkit"]

[project]
name = "pgdevkit"
version = "0.2.2"
version = "0.2.3"
description = "A helper for developing with Postgres"
readme = "README.md"
requires-python = ">=3.14"
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading