From cee01482ec89710b166ac27ef43307518068a6a5 Mon Sep 17 00:00:00 2001 From: Roman Podoliaka Date: Fri, 4 Nov 2016 16:00:15 +0200 Subject: [PATCH] utils: deprecate InsertFromSelect properly This is provided out-of-box by SQLAlchemy versions >= 1.0.0. We've had this class deprecated in docs for some time now, now do it properly by the means of debtcollector and a release note. Closes-Bug: #1439092 Change-Id: I562c35c265014c6b19a81961f236a7a0ca438765 --- oslo_db/sqlalchemy/utils.py | 10 ++++++---- .../deprecate-insert-from-select-ea831381ebd7e7cf.yaml | 6 ++++++ 2 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/deprecate-insert-from-select-ea831381ebd7e7cf.yaml diff --git a/oslo_db/sqlalchemy/utils.py b/oslo_db/sqlalchemy/utils.py index 87c6f071..8ce7c2ab 100644 --- a/oslo_db/sqlalchemy/utils.py +++ b/oslo_db/sqlalchemy/utils.py @@ -22,6 +22,7 @@ import itertools import logging import re +import debtcollector from oslo_utils import timeutils import six import sqlalchemy @@ -415,13 +416,14 @@ def get_table(engine, name): return Table(name, metadata, autoload=True) +@debtcollector.removals.removed_class( + 'InsertFromSelect', + replacement='sqlalchemy.sql.expression.Insert.from_select', + message='this functionality is provided out-of-box by SQLAlchemy >= 1.0.0' +) class InsertFromSelect(object): """Form the base for `INSERT INTO table (SELECT ... )` statement. - DEPRECATED: this class is deprecated and will be removed from oslo_db - in a few releases. Use default SQLAlchemy insert from select implementation - instead - :param table: table to insert records :param select: select query :param cols: list of columns to specify in insert clause diff --git a/releasenotes/notes/deprecate-insert-from-select-ea831381ebd7e7cf.yaml b/releasenotes/notes/deprecate-insert-from-select-ea831381ebd7e7cf.yaml new file mode 100644 index 00000000..88a06e2b --- /dev/null +++ b/releasenotes/notes/deprecate-insert-from-select-ea831381ebd7e7cf.yaml @@ -0,0 +1,6 @@ +--- +deprecations: + - class ``InsertFromSelect`` from module ``oslo_db.sqlalchemy.utils`` is + deprecated in favor of ``sqlalchemy.sql.expression.Insert.from_select()`` + method of Insert expression, that is available in SQLAlchemy versions + 1.0.0 and newer