From: Federico Caselli Date: Fri, 10 Apr 2020 19:38:02 +0000 (+0200) Subject: The :meth:`.Inspector.reflecttable` was renamed to :meth:`.Inspector.reflect_table`. X-Git-Tag: rel_1_4_0b1~401^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b10414c8974625622dfff08262272b39bcff85e;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git The :meth:`.Inspector.reflecttable` was renamed to :meth:`.Inspector.reflect_table`. Fixes: #5244 Change-Id: I2b12fd69ed24ce1ede8f6ed5cb14cc7761308ee3 --- diff --git a/doc/build/changelog/unreleased_14/5244.rst b/doc/build/changelog/unreleased_14/5244.rst new file mode 100644 index 0000000000..c6a7520b0d --- /dev/null +++ b/doc/build/changelog/unreleased_14/5244.rst @@ -0,0 +1,6 @@ +.. change:: + :tags: change, reflection + :tickets: 5244 + + The :meth:`.Inspector.reflecttable` was renamed to + :meth:`.Inspector.reflect_table`. \ No newline at end of file diff --git a/lib/sqlalchemy/engine/reflection.py b/lib/sqlalchemy/engine/reflection.py index 85e671421b..1a34e9c72e 100644 --- a/lib/sqlalchemy/engine/reflection.py +++ b/lib/sqlalchemy/engine/reflection.py @@ -645,7 +645,17 @@ class Inspector(object): conn, table_name, schema, info_cache=self.info_cache, **kw ) - def reflecttable( + @util.deprecated_20( + ":meth:`.Inspector.reflecttable`", + "The :meth:`.Inspector.reflecttable` method was renamed to " + ":meth:`.Inspector.reflect_table`. This deprecated alias " + "will be removed in a future release.", + ) + def reflecttable(self, *args, **kwargs): + "See reflect_table. This method name is deprecated" + return self.reflect_table(*args, **kwargs) + + def reflect_table( self, table, include_columns, @@ -666,7 +676,10 @@ class Inspector(object): meta = MetaData() user_table = Table('user', meta) insp = Inspector.from_engine(engine) - insp.reflecttable(user_table, None) + insp.reflect_table(user_table, None) + + .. versionchanged:: 1.4 Renamed from ``reflecttable`` to + ``reflect_table`` :param table: a :class:`~sqlalchemy.schema.Table` instance. :param include_columns: a list of string column names to include diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py index d1abaed3b0..56695708e3 100644 --- a/lib/sqlalchemy/sql/schema.py +++ b/lib/sqlalchemy/sql/schema.py @@ -578,7 +578,7 @@ class Table(DialectKWArgs, SchemaItem, TableClause): ) insp = inspection.inspect(autoload_with) - insp.reflecttable( + insp.reflect_table( self, include_columns, exclude_columns, diff --git a/test/engine/test_deprecations.py b/test/engine/test_deprecations.py index c9bf83f315..53df6c1a8e 100644 --- a/test/engine/test_deprecations.py +++ b/test/engine/test_deprecations.py @@ -2,6 +2,7 @@ import sqlalchemy as tsa from sqlalchemy import create_engine from sqlalchemy import ForeignKey from sqlalchemy import func +from sqlalchemy import inspect from sqlalchemy import INT from sqlalchemy import Integer from sqlalchemy import MetaData @@ -524,6 +525,18 @@ class DeprecatedReflectionTest(fixtures.TablesTest): table_names = testing.db.table_names() is_true(set(table_names).issuperset(metadata.tables)) + def test_reflecttable(self): + inspector = inspect(testing.db) + metadata = self.metadata + table = Table("user", metadata) + with testing.expect_deprecated_20( + r"The Inspector.reflecttable\(\) function/method is considered " + ): + res = inspector.reflecttable(table, None) + exp = inspector.reflect_table(table, None) + + eq_(res, exp) + class ExecutionOptionsTest(fixtures.TestBase): def test_branched_connection_execution_options(self): diff --git a/test/engine/test_reflection.py b/test/engine/test_reflection.py index 3a2a3c6994..0fea029fea 100644 --- a/test/engine/test_reflection.py +++ b/test/engine/test_reflection.py @@ -1282,15 +1282,15 @@ class ReflectionTest(fixtures.TestBase, ComparesTables): m = MetaData() inspector = sa.engine.reflection.Inspector - reflecttable = inspector.reflecttable + reflect_table = inspector.reflect_table def patched(self, table, *arg, **kw): if table.name == "rt_c": raise sa.exc.UnreflectableTableError("Can't reflect rt_c") else: - return reflecttable(self, table, *arg, **kw) + return reflect_table(self, table, *arg, **kw) - with mock.patch.object(inspector, "reflecttable", patched): + with mock.patch.object(inspector, "reflect_table", patched): with expect_warnings("Skipping table rt_c: Can't reflect rt_c"): m.reflect(bind=testing.db) @@ -1685,7 +1685,7 @@ class UnicodeReflectionTest(fixtures.TestBase): @testing.requires.unicode_connections def test_basic(self): # the 'convert_unicode' should not get in the way of the - # reflection process. reflecttable for oracle, postgresql + # reflection process. reflect_table for oracle, postgresql # (others?) expect non-unicode strings in result sets/bind # params