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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
run: python -m pip install tox

- name: Run tox
run: tox
run: tox -v

lint:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pip install pgspot
## Requirements

- python >= 3.10
- [pglast >= 3.13](https://github.com/lelit/pglast)
- [pglast == 4.1](https://github.com/lelit/pglast)
- [libpg_query](https://github.com/pganalyze/libpg_query) (through pglast)

To install the runtime requirements, use `pip -r requirements.txt`.
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pglast>=3.13
pglast==4.1
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ packages = find:
python_requires = >= 3.10

install_requires =
pglast>=3.11
pglast==4.1

tests_require =
pytest
Expand Down
12 changes: 12 additions & 0 deletions src/pgspot/visitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ def visit(self, node):
if isinstance(node, dict):
for key, value in node.items():
match (key):
# work around inconsistent expression handling for assert and return statement in pglast
case "PLpgSQL_stmt_assert":
visit_sql(
self.state,
"SELECT " + value["cond"]["PLpgSQL_expr"]["query"],
)
case "PLpgSQL_stmt_return":
if value:
visit_sql(
self.state,
"SELECT " + value["expr"]["PLpgSQL_expr"]["query"],
)
case "PLpgSQL_expr":
visit_sql(self.state, value["query"])
case _:
Expand Down