summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/__init__.py
diff options
context:
space:
mode:
authorGord Thompson <gord@gordthompson.com>2021-01-09 14:56:38 -0700
committerMike Bayer <mike_mp@zzzcomputing.com>2021-01-26 16:52:30 -0500
commit22f65156bbe846dea2fb9f87fe4187abe0ed790a (patch)
treef49338a10dd2800d4d754b14d2e7fd549b4b833f /lib/sqlalchemy/__init__.py
parent7bdb1f30f66aaea16efbcf96e314491058493e6c (diff)
downloadsqlalchemy-22f65156bbe846dea2fb9f87fe4187abe0ed790a.tar.gz
Replace with_labels() and apply_labels() in ORM/Core
Replace :meth:`_orm.Query.with_labels` and :meth:`_sql.GenerativeSelect.apply_labels` with explicit getters and setters ``get_label_style`` and ``set_label_style`` to accommodate the three supported label styles: ``LABEL_STYLE_DISAMBIGUATE_ONLY`` (default), ``LABEL_STYLE_TABLENAME_PLUS_COL``, and ``LABEL_STYLE_NONE``. In addition, for Core and "future style" ORM queries, ``LABEL_STYLE_DISAMBIGUATE_ONLY`` is now the default label style. This style differs from the existing "no labels" style in that labeling is applied in the case of column name conflicts; with ``LABEL_STYLE_NONE``, a duplicate column name is not accessible via name in any case. For legacy ORM queries using :class:`_query.Query`, the table-plus-column names labeling style applied by ``LABEL_STYLE_TABLENAME_PLUS_COL`` continues to be used so that existing test suites and logging facilities see no change in behavior by default, however this style of labeling is no longer required for SQLAlchemy queries to function, as result sets are commonly matched to columns using a positional approach since SQLAlchemy 1.0. Within test suites, all use of apply_labels() / use_labels now uses the new methods. New tests added to test/sql/test_deprecations.py nad test/orm/test_deprecations.py to cover just the old apply_labels() method call. Tests in ORM that made explicit use apply_labels()/ etc. where it isn't needed for the ORM to work correctly use default label style now. Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Fixes: #4757 Change-Id: I5fdcd2ed4ae8c7fe62f8be2b6d0e8f66409b6a54
Diffstat (limited to 'lib/sqlalchemy/__init__.py')
-rw-r--r--lib/sqlalchemy/__init__.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/sqlalchemy/__init__.py b/lib/sqlalchemy/__init__.py
index 607585460..2d092be65 100644
--- a/lib/sqlalchemy/__init__.py
+++ b/lib/sqlalchemy/__init__.py
@@ -54,6 +54,10 @@ from .sql import insert # noqa
from .sql import intersect # noqa
from .sql import intersect_all # noqa
from .sql import join # noqa
+from .sql import LABEL_STYLE_DEFAULT # noqa
+from .sql import LABEL_STYLE_DISAMBIGUATE_ONLY # noqa
+from .sql import LABEL_STYLE_NONE # noqa
+from .sql import LABEL_STYLE_TABLENAME_PLUS_COL # noqa
from .sql import lambda_stmt # noqa
from .sql import lateral # noqa
from .sql import literal # noqa