]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
The :meth:`.Inspector.reflecttable` was renamed to :meth:`.Inspector.reflect_table`.
authorFederico Caselli <cfederico87@gmail.com>
Fri, 10 Apr 2020 19:38:02 +0000 (21:38 +0200)
committerFederico Caselli <cfederico87@gmail.com>
Fri, 10 Apr 2020 21:25:07 +0000 (23:25 +0200)
Fixes: #5244
Change-Id: I2b12fd69ed24ce1ede8f6ed5cb14cc7761308ee3

doc/build/changelog/unreleased_14/5244.rst [new file with mode: 0644]
lib/sqlalchemy/engine/reflection.py
lib/sqlalchemy/sql/schema.py
test/engine/test_deprecations.py
test/engine/test_reflection.py

diff --git a/doc/build/changelog/unreleased_14/5244.rst b/doc/build/changelog/unreleased_14/5244.rst
new file mode 100644 (file)
index 0000000..c6a7520
--- /dev/null
@@ -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
index 85e671421b3856a4644248459d9909172f88c201..1a34e9c72ed531873f89da52ed4747ef22ec5b56 100644 (file)
@@ -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
index d1abaed3b0f9d637337fb712a0b1d65f9d0ac9bd..56695708e359c3550f3b602ac50d869cf0e4cde7 100644 (file)
@@ -578,7 +578,7 @@ class Table(DialectKWArgs, SchemaItem, TableClause):
             )
 
         insp = inspection.inspect(autoload_with)
-        insp.reflecttable(
+        insp.reflect_table(
             self,
             include_columns,
             exclude_columns,
index c9bf83f3156c7d4f99aeaca75d8a39ea2c3a6daf..53df6c1a8eca726d5d7d1ceccb9279aed266a6bd 100644 (file)
@@ -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):
index 3a2a3c6994d2b58ee562458f373640e2bfae042b..0fea029feae5faa82f1467c8eaf36f35340cf3c7 100644 (file)
@@ -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