]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Default psycopg2 executemany mode to "values_only"
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 23 Jun 2020 20:21:04 +0000 (16:21 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 25 Jun 2020 22:58:34 +0000 (18:58 -0400)
commitf1a3038f480ee1965928cdcd1dc0c47347f270bc
tree8b03334c438631e72f132533db676b3bf25a3f00
parent660a340bff8fcefd2826032e75210c0924a2335e
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
39 files changed:
doc/build/changelog/migration_14.rst
doc/build/changelog/unreleased_14/5401.rst [new file with mode: 0644]
doc/build/changelog/unreleased_14/psycopg2_27.rst [new file with mode: 0644]
doc/build/conf.py
doc/build/core/tutorial.rst
lib/sqlalchemy/dialects/postgresql/psycopg2.py
lib/sqlalchemy/engine/base.py
lib/sqlalchemy/engine/cursor.py
lib/sqlalchemy/engine/default.py
lib/sqlalchemy/orm/persistence.py
lib/sqlalchemy/sql/compiler.py
lib/sqlalchemy/sql/crud.py
lib/sqlalchemy/sql/dml.py
lib/sqlalchemy/sql/elements.py
lib/sqlalchemy/testing/assertions.py
lib/sqlalchemy/testing/assertsql.py
lib/sqlalchemy/testing/requirements.py
lib/sqlalchemy/testing/suite/test_insert.py
lib/sqlalchemy/testing/suite/test_sequence.py
setup.cfg
test/dialect/mssql/test_query.py
test/dialect/mysql/test_on_duplicate.py
test/dialect/postgresql/test_compiler.py
test/dialect/postgresql/test_dialect.py
test/dialect/postgresql/test_on_conflict.py
test/dialect/postgresql/test_query.py
test/dialect/postgresql/test_reflection.py
test/dialect/postgresql/test_types.py
test/orm/test_naturalpks.py
test/requirements.py
test/sql/test_defaults.py
test/sql/test_deprecations.py
test/sql/test_functions.py
test/sql/test_insert.py
test/sql/test_insert_exec.py
test/sql/test_returning.py
test/sql/test_sequences.py
test/sql/test_update.py
tox.ini