From 2f617f56f2acdce00b88f746c403cf5ed66d4d27 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 7 Apr 2020 14:15:43 -0400 Subject: Create initial 2.0 engine implementation Implemented the SQLAlchemy 2 :func:`.future.create_engine` function which is used for forwards compatibility with SQLAlchemy 2. This engine features always-transactional behavior with autobegin. Allow execution options per statement execution. This includes that the before_execute() and after_execute() events now accept an additional dictionary with these options, empty if not passed; a legacy event decorator is added for backwards compatibility which now also emits a deprecation warning. Add some basic tests for execution, transactions, and the new result object. Build out on a new testing fixture that swaps in the future engine completely to start with. Change-Id: I70e7338bb3f0ce22d2f702537d94bb249bd9fb0a Fixes: #4644 --- lib/sqlalchemy/dialects/postgresql/base.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy/dialects/postgresql/base.py') diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index f9b3d9b95..20540ac02 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -2753,7 +2753,7 @@ class PGDialect(default.DefaultDialect): s = s.columns(oid=sqltypes.Integer) if schema: s = s.bindparams(sql.bindparam("schema", type_=sqltypes.Unicode)) - c = connection.execute(s, table_name=table_name, schema=schema) + c = connection.execute(s, dict(table_name=table_name, schema=schema)) table_oid = c.scalar() if table_oid is None: raise exc.NoSuchTableError(table_name) @@ -3519,7 +3519,9 @@ class PGDialect(default.DefaultDialect): pgd.objoid = :table_oid """ - c = connection.execute(sql.text(COMMENT_SQL), table_oid=table_oid) + c = connection.execute( + sql.text(COMMENT_SQL), dict(table_oid=table_oid) + ) return {"text": c.scalar()} @reflection.cache -- cgit v1.2.1