PG Grant is not compatible with SQLAlchemy 2.0
Closed this issue · 4 comments
jjmurre commented
Reproduction:
- create an virtualenv
- pip install pg_grant[sqlalchemy]
- make sure that version of sqlalchemy >= 1.4.x has been installed (in output of pip command)
- start python interpreter
>>> from pg_grant import query
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/tmp/pgg/.venv/lib/python3.9/site-packages/pg_grant/query.py", line 128, in <module>
select([
File "/tmp/pgg/.venv/lib/python3.9/site-packages/sqlalchemy/sql/_selectable_constructors.py", line 493, in select
return Select(*entities)
File "/tmp/pgg/.venv/lib/python3.9/site-packages/sqlalchemy/sql/selectable.py", line 5219, in __init__
self._raw_columns = [
File "/tmp/pgg/.venv/lib/python3.9/site-packages/sqlalchemy/sql/selectable.py", line 5220, in <listcomp>
coercions.expect(
File "/tmp/pgg/.venv/lib/python3.9/site-packages/sqlalchemy/sql/coercions.py", line 413, in expect
resolved = impl._literal_coercion(
File "/tmp/pgg/.venv/lib/python3.9/site-packages/sqlalchemy/sql/coercions.py", line 652, in _literal_coercion
self._raise_for_expected(element, argname)
File "/tmp/pgg/.venv/lib/python3.9/site-packages/sqlalchemy/sql/coercions.py", line 1143, in _raise_for_expected
return super()._raise_for_expected(
File "/tmp/pgg/.venv/lib/python3.9/site-packages/sqlalchemy/sql/coercions.py", line 711, in _raise_for_expected
super()._raise_for_expected(
File "/tmp/pgg/.venv/lib/python3.9/site-packages/sqlalchemy/sql/coercions.py", line 536, in _raise_for_expected
raise exc.ArgumentError(msg, code=code) from err
sqlalchemy.exc.ArgumentError: Column expression, FROM clause, or other columns clause element expected, got [<sqlalchemy.sql.elements.ColumnClause at 0x7f78ecc7aa90; oid>, <sqlalchemy.sql.elements.Label at 0x7f78ecc6bee0; schema>, <sqlalchemy.sql.elements.Label at 0x7f78ecc7a220; name>, <sqlalchemy.sql.elements.Label at 0x7f78ecc6be20; owner>, <sqlalchemy.sql.elements.Label at 0x7f78ecc86220; acl>]. Did you mean to say select(<sqlalchemy.sql.elements.ColumnClause at 0x7f78ecc7aa90; oid>, <sqlalchemy.sql.elements.Label at 0x7f78ecc6bee0; schema>, <sqlalchemy.sql.elements.Label at 0x7f78ecc7a220; name>, <sqlalchemy.sql.elements.Label at 0x7f78ecc6be20; owner>, <sqlalchemy.sql.elements.Label at 0x7f78ecc86220; acl>)?
jjmurre commented
See: https://docs.sqlalchemy.org/en/14/core/tutorial.html#selecting
Changed in version 1.4: The select() construct now accepts column arguments positionally, as select(*args). The previous style of select() accepting a list of column elements is now deprecated. See select(), case() now accept positional expressions.
However, it seems that it is not only deprecated, but just crashes on a list of column elements.
RazerM commented
I suspect you're using SQLAlchemy 2.0.
I'll try to get it fixed ASAP, you should be able to stay on 1.4 in the meantime.
RazerM commented
I've confirmed that pg_grant supports SQLAlchemy 1.4, and have merge requests for SQLAlchemy 1.4 and 2.0 testing.
RazerM commented
pg_grant 0.4.0 has been released with SQLAlchemy 2.0 support