summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/build/changelog/unreleased_14/5244.rst6
-rw-r--r--lib/sqlalchemy/engine/reflection.py17
-rw-r--r--lib/sqlalchemy/sql/schema.py2
-rw-r--r--test/engine/test_deprecations.py13
-rw-r--r--test/engine/test_reflection.py8
5 files changed, 39 insertions, 7 deletions
diff --git a/doc/build/changelog/unreleased_14/5244.rst b/doc/build/changelog/unreleased_14/5244.rst
new file mode 100644
index 000000000..c6a7520b0
--- /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 85e671421..1a34e9c72 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 d1abaed3b..56695708e 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 c9bf83f31..53df6c1a8 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 3a2a3c699..0fea029fe 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