diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 328b0cd..6c0822b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,7 @@ jobs: run: python -m pip install tox - name: Run tox - run: tox + run: tox -v lint: runs-on: ubuntu-latest diff --git a/README.md b/README.md index 27bd8f4..3f5316e 100644 --- a/README.md +++ b/README.md @@ -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`. diff --git a/requirements.txt b/requirements.txt index 124b9f3..362d540 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -pglast>=3.13 +pglast==4.1 diff --git a/setup.cfg b/setup.cfg index d43b729..2daf4aa 100644 --- a/setup.cfg +++ b/setup.cfg @@ -28,7 +28,7 @@ packages = find: python_requires = >= 3.10 install_requires = - pglast>=3.11 + pglast==4.1 tests_require = pytest diff --git a/src/pgspot/visitors.py b/src/pgspot/visitors.py index 29d6856..ce11979 100644 --- a/src/pgspot/visitors.py +++ b/src/pgspot/visitors.py @@ -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 _: