diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-06-23 16:21:04 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-06-25 18:58:34 -0400 |
commit | f1a3038f480ee1965928cdcd1dc0c47347f270bc (patch) | |
tree | 8b03334c438631e72f132533db676b3bf25a3f00 /test/dialect/postgresql/test_reflection.py | |
parent | 660a340bff8fcefd2826032e75210c0924a2335e (diff) | |
download | sqlalchemy-f1a3038f480ee1965928cdcd1dc0c47347f270bc.tar.gz |
Default psycopg2 executemany mode to "values_only"
The psycopg2 dialect now defaults to using the very performant
``execute_values()`` psycopg2 extension for compiled INSERT statements,
and also impements RETURNING support when this extension is used. This
allows INSERT statements that even include an autoincremented SERIAL
or IDENTITY value to run very fast while still being able to return the
newly generated primary key values. The ORM will then integrate this
new feature in a separate change.
Implements RETURNING for insert with executemany
Adds support to return_defaults() mode and inserted_primary_key
to support mutiple INSERTed rows, via return_defauls_rows
and inserted_primary_key_rows accessors.
within default execution context, new cached compiler
getters are used to fetch primary keys from rows
inserted_primary_key now returns a plain tuple. this
is not yet a row-like object however this can be
added.
Adds distinct "values_only" and "batch" modes, as
"values" has a lot of benefits but "batch" breaks
cursor.rowcount
psycopg2 minimum version 2.7 so we can remove the
large number of checks for very old versions of
psycopg2
simplify tests to no longer distinguish between
native and non-native json
Fixes: #5401
Change-Id: Ic08fd3423d4c5d16ca50994460c0c234868bd61c
Diffstat (limited to 'test/dialect/postgresql/test_reflection.py')
-rw-r--r-- | test/dialect/postgresql/test_reflection.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/test/dialect/postgresql/test_reflection.py b/test/dialect/postgresql/test_reflection.py index 89d4ae081..ec9328c2f 100644 --- a/test/dialect/postgresql/test_reflection.py +++ b/test/dialect/postgresql/test_reflection.py @@ -488,7 +488,7 @@ class ReflectionTest(fixtures.TestBase): t2 = Table("t", m2, autoload=True, implicit_returning=False) eq_(t2.c.id.server_default.arg.text, "nextval('t_id_seq'::regclass)") r = t2.insert().execute() - eq_(r.inserted_primary_key, [1]) + eq_(r.inserted_primary_key, (1,)) testing.db.connect().execution_options( autocommit=True ).exec_driver_sql("alter table t_id_seq rename to foobar_id_seq") @@ -499,7 +499,7 @@ class ReflectionTest(fixtures.TestBase): "nextval('foobar_id_seq'::regclass)", ) r = t3.insert().execute() - eq_(r.inserted_primary_key, [2]) + eq_(r.inserted_primary_key, (2,)) @testing.provide_metadata def test_altered_type_autoincrement_pk_reflection(self): |