aiopg: aiopg 1.1.0+ is incompatible with SQLAlchemy 1.4

Aiopg will automatically download SQLAlchemy 1.4.0(Released March 15) which leads to crazy errors due to incompatibility. Make sure to freeze SQLAlchemy==1.3.23.

Two specific issues i noticed:

  1. Failure when doing a select. What i found that the query is absolutely valid and Postgres returns what is expected, but the RowProxy fails to map the columns.
self = <[InvalidRequestError("Ambiguous column name 'None' in result set! try 'use_labels' option on select statement.") raised in repr()] RowProxy object at 0x7fccab231460>
key = 'brands_id'

     def __getitem__(self, key):
         try:
>           processor, obj, index = self._keymap[key]
E           KeyError: 'brands_id'

/usr/local/lib/python3.7/site-packages/aiopg/sa/result.py:27: KeyError

During handling of the above exception, another exception occurred:

tables = None, sa_engine = <aiopg.sa.engine.Engine object at 0x7fccab2813d0>
  1. Failure when Deleting from table. Honestly i’m not sure if aiopg is responsible for that, it may very well be psycopg2.
E           psycopg2.errors.SyntaxError: syntax error at or near "["
E           LINE 1: ...ETE FROM materials WHERE materials.product_id IN ([POSTCOMPI...
E                                                                        ^

/usr/local/lib/python3.7/site-packages/aiopg/connection.py:106: SyntaxError

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 23 (12 by maintainers)

Most upvoted comments

The proper fix is dropping aiopg.sa subsystem at all.

You can ‘apply’ this fix right now by just switching from aiopg.sa usage to sqlalchemy in async mode. Years ago, when sqlalchemy didn’t support async, aiopg.sa made a value. Now it is just garbage, please use upstream.

Not at the moment. Need to get familiar with changes introduced in new SQLAlchemy release

  1. Second happens due to adding caching layer to sqlalchemy 1.4.2 https://docs.sqlalchemy.org/en/14/changelog/migration_14.html#all-in-expressions-render-parameters-for-each-value-in-the-list-on-the-fly-e-g-expanding-parameters

In order to use cache effectively literal values are precompiled to [POSTCOMPILE_\d+] and substituted before execution, after cache lookup