]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Add max_identifier_length parameter; warn for Oracle
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 2 Oct 2019 15:20:58 +0000 (11:20 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 2 Oct 2019 18:55:11 +0000 (14:55 -0400)
commit5188afe8703b7c8e03086d3898a4f44038316a57
tree72263c3a8f67137064bce4c65a5fb43f29ac30ba
parent1e0e096454682479189d7a59cab515f3a4a3d20e
Add max_identifier_length parameter; warn for Oracle

Added new :func:`.create_engine` parameter
:paramref:`.create_engine.max_identifier_length`. This overrides the
dialect-coded "max identifier length" in order to accommodate for databases
that have recently changed this length and the SQLAlchemy dialect has
not yet been adjusted to detect for that version.  This parameter interacts
with the existing :paramref:`.create_engine.label_length` parameter in that
it establishes the maximum (and default) value for anonymously generated
labels.

The Oracle dialect now emits a warning if Oracle version 12.2 or greater is
used, and the :paramref:`.create_engine.max_identifier_length` parameter is
not set.   The version in this specific case defaults to that of the
"compatibility" version set in the Oracle server configuration, not the
actual server version.   In version 1.4, the default max_identifier_length
for 12.2 or greater will move to 128 characters.  In order to maintain
forwards compatibility, applications should set
:paramref:`.create_engine.max_identifier_length` to 30 in order to maintain
the same length behavior, or to 128 in order to test the upcoming behavior.
This length determines among other things how generated constraint names
are truncated for statements like ``CREATE CONSTRAINT`` and ``DROP
CONSTRAINT``, which means a the new length may produce a name-mismatch
against a name that was generated with the old length, impacting database
migrations.

Fixes: #4857
Change-Id: Ib62efb00c6180c375869029b57353d90385d7950
(cherry picked from commit 88761b8b0b0cfa67cdd6a4913e3a0ea5cba93cbb)
doc/build/changelog/unreleased_13/4857.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/oracle/base.py
lib/sqlalchemy/engine/__init__.py
lib/sqlalchemy/engine/default.py
lib/sqlalchemy/testing/warnings.py
test/dialect/oracle/test_dialect.py
test/sql/test_labels.py