summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGord Thompson <gord@gordthompson.com>2020-06-27 08:53:23 -0600
committerMike Bayer <mike_mp@zzzcomputing.com>2020-06-29 13:56:21 -0400
commit2c1e517d0368934b70a571163ff56638673cc96b (patch)
treefb4e65ab5372cf2e89984ccd1590fc43f27c99c4
parent5f5b56d646f154ee572c9de80449423304103bad (diff)
downloadsqlalchemy-2c1e517d0368934b70a571163ff56638673cc96b.tar.gz
Rename Table.tometadata to to_metadata
Renamed the :meth:`_schema.Table.tometadata` method to :meth:`_schema.Table.to_metadata`. The previous name remains with a deprecation warning. Updated the "decorate" utility function to support decoration of functions that include non-builtins as default values. Moves test for deprecated "databases" package into test/dialect/test_deprecations.py Fixes: #5413 Fixes: #5426 Change-Id: I6ed899871c935f9e46360127c17ccb7cf97cea6e
-rw-r--r--doc/build/changelog/unreleased_14/5413.rst7
-rw-r--r--doc/build/conf.py1
-rw-r--r--lib/sqlalchemy/sql/events.py18
-rw-r--r--lib/sqlalchemy/sql/schema.py39
-rw-r--r--lib/sqlalchemy/sql/sqltypes.py2
-rw-r--r--lib/sqlalchemy/util/langhelpers.py31
-rw-r--r--test/dialect/postgresql/test_compiler.py2
-rw-r--r--test/dialect/test_deprecations.py (renamed from test/test_deprecations.py)8
-rw-r--r--test/orm/test_bind.py10
-rw-r--r--test/sql/test_compiler.py2
-rw-r--r--test/sql/test_computed.py4
-rw-r--r--test/sql/test_deprecations.py13
-rw-r--r--test/sql/test_metadata.py88
13 files changed, 149 insertions, 76 deletions
diff --git a/doc/build/changelog/unreleased_14/5413.rst b/doc/build/changelog/unreleased_14/5413.rst
new file mode 100644
index 000000000..8be68eb74
--- /dev/null
+++ b/doc/build/changelog/unreleased_14/5413.rst
@@ -0,0 +1,7 @@
+.. change::
+ :tags: deprecations, schema
+ :tickets: 5413
+
+ Renamed the :meth:`_schema.Table.tometadata` method to
+ :meth:`_schema.Table.to_metadata`. The previous name remains with a
+ deprecation warning.
diff --git a/doc/build/conf.py b/doc/build/conf.py
index b2561f9fc..710ab58fe 100644
--- a/doc/build/conf.py
+++ b/doc/build/conf.py
@@ -154,6 +154,7 @@ zzzeeksphinx_module_prefixes = {
"_mssql": "sqlalchemy.dialects.mssql",
"_oracle": "sqlalchemy.dialects.oracle",
"_sqlite": "sqlalchemy.dialects.sqlite",
+ "_util": "sqlalchemy.util",
}
diff --git a/lib/sqlalchemy/sql/events.py b/lib/sqlalchemy/sql/events.py
index 51556d929..d7836a5a0 100644
--- a/lib/sqlalchemy/sql/events.py
+++ b/lib/sqlalchemy/sql/events.py
@@ -60,7 +60,7 @@ class DDLEvents(event.Events):
For all :class:`.DDLEvent` events, the ``propagate=True`` keyword argument
will ensure that a given event handler is propagated to copies of the
- object, which are made when using the :meth:`_schema.Table.tometadata`
+ object, which are made when using the :meth:`_schema.Table.to_metadata`
method::
from sqlalchemy import DDL
@@ -71,7 +71,7 @@ class DDLEvents(event.Events):
propagate=True
)
- new_table = some_table.tometadata(new_metadata)
+ new_table = some_table.to_metadata(new_metadata)
The above :class:`.DDL` object will also be associated with the
:class:`_schema.Table` object represented by ``new_table``.
@@ -109,7 +109,7 @@ class DDLEvents(event.Events):
modifier for this event; when True, the listener function will
be established for any copies made of the target object,
i.e. those copies that are generated when
- :meth:`_schema.Table.tometadata` is used.
+ :meth:`_schema.Table.to_metadata` is used.
"""
@@ -131,7 +131,7 @@ class DDLEvents(event.Events):
modifier for this event; when True, the listener function will
be established for any copies made of the target object,
i.e. those copies that are generated when
- :meth:`_schema.Table.tometadata` is used.
+ :meth:`_schema.Table.to_metadata` is used.
"""
@@ -153,7 +153,7 @@ class DDLEvents(event.Events):
modifier for this event; when True, the listener function will
be established for any copies made of the target object,
i.e. those copies that are generated when
- :meth:`_schema.Table.tometadata` is used.
+ :meth:`_schema.Table.to_metadata` is used.
"""
@@ -175,7 +175,7 @@ class DDLEvents(event.Events):
modifier for this event; when True, the listener function will
be established for any copies made of the target object,
i.e. those copies that are generated when
- :meth:`_schema.Table.tometadata` is used.
+ :meth:`_schema.Table.to_metadata` is used.
"""
@@ -190,7 +190,7 @@ class DDLEvents(event.Events):
modifier for this event; when True, the listener function will
be established for any copies made of the target object,
i.e. those copies that are generated when
- :meth:`_schema.Table.tometadata` is used.
+ :meth:`_schema.Table.to_metadata` is used.
"""
@@ -205,7 +205,7 @@ class DDLEvents(event.Events):
modifier for this event; when True, the listener function will
be established for any copies made of the target object,
i.e. those copies that are generated when
- :meth:`_schema.Table.tometadata` is used.
+ :meth:`_schema.Table.to_metadata` is used.
"""
@@ -284,6 +284,6 @@ class DDLEvents(event.Events):
modifier for this event; when True, the listener function will
be established for any copies made of the target object,
i.e. those copies that are generated when
- :meth:`_schema.Table.tometadata` is used.
+ :meth:`_schema.Table.to_metadata` is used.
"""
diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py
index 3df1c9f91..ac6276c1c 100644
--- a/lib/sqlalchemy/sql/schema.py
+++ b/lib/sqlalchemy/sql/schema.py
@@ -867,6 +867,11 @@ class Table(DialectKWArgs, SchemaItem, TableClause):
bind = _bind_or_error(self)
bind._run_ddl_visitor(ddl.SchemaDropper, self, checkfirst=checkfirst)
+ @util.deprecated(
+ "1.4",
+ ":meth:`_schema.Table.tometadata` is renamed to "
+ ":meth:`_schema.Table.to_metadata`",
+ )
def tometadata(
self,
metadata,
@@ -878,6 +883,26 @@ class Table(DialectKWArgs, SchemaItem, TableClause):
associated with a different
:class:`_schema.MetaData`.
+ See :meth:`_schema.Table.to_metadata` for a full description.
+
+ """
+ return self.to_metadata(
+ metadata,
+ schema=schema,
+ referred_schema_fn=referred_schema_fn,
+ name=name,
+ )
+
+ def to_metadata(
+ self,
+ metadata,
+ schema=RETAIN_SCHEMA,
+ referred_schema_fn=None,
+ name=None,
+ ):
+ """Return a copy of this :class:`_schema.Table` associated with a
+ different :class:`_schema.MetaData`.
+
E.g.::
m1 = MetaData()
@@ -885,7 +910,11 @@ class Table(DialectKWArgs, SchemaItem, TableClause):
user = Table('user', m1, Column('id', Integer, primary_key=True))
m2 = MetaData()
- user_copy = user.tometadata(m2)
+ user_copy = user.to_metadata(m2)
+
+ .. versionchanged:: 1.4 The :meth:`_schema.Table.to_metadata` function
+ was renamed from :meth:`_schema.Table.tometadata`.
+
:param metadata: Target :class:`_schema.MetaData` object,
into which the
@@ -905,12 +934,12 @@ class Table(DialectKWArgs, SchemaItem, TableClause):
m2 = MetaData(schema='newschema')
# user_copy_one will have "newschema" as the schema name
- user_copy_one = user.tometadata(m2, schema=None)
+ user_copy_one = user.to_metadata(m2, schema=None)
m3 = MetaData() # schema defaults to None
# user_copy_two will have None as the schema name
- user_copy_two = user.tometadata(m3, schema=None)
+ user_copy_two = user.to_metadata(m3, schema=None)
:param referred_schema_fn: optional callable which can be supplied
in order to provide for the schema name that should be assigned
@@ -929,7 +958,7 @@ class Table(DialectKWArgs, SchemaItem, TableClause):
else:
return to_schema
- new_table = table.tometadata(m2, schema="alt_schema",
+ new_table = table.to_metadata(m2, schema="alt_schema",
referred_schema_fn=referred_schema_fn)
.. versionadded:: 0.9.2
@@ -1548,7 +1577,7 @@ class Column(DialectKWArgs, SchemaItem, ColumnClause):
def copy(self, **kw):
"""Create a copy of this ``Column``, uninitialized.
- This is used in :meth:`_schema.Table.tometadata`.
+ This is used in :meth:`_schema.Table.to_metadata`.
"""
diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py
index 5d7f80b1b..186f885d8 100644
--- a/lib/sqlalchemy/sql/sqltypes.py
+++ b/lib/sqlalchemy/sql/sqltypes.py
@@ -1391,7 +1391,7 @@ class Enum(Emulated, String, SchemaType):
will be copied to the "schema" attribute of this
:class:`.Enum`, replacing whatever value was passed for the
``schema`` attribute. This also takes effect when using the
- :meth:`_schema.Table.tometadata` operation.
+ :meth:`_schema.Table.to_metadata` operation.
:param validate_strings: when True, string values that are being
passed to the database in a SQL statement will be checked
diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py
index 52debc517..57d3be83b 100644
--- a/lib/sqlalchemy/util/langhelpers.py
+++ b/lib/sqlalchemy/util/langhelpers.py
@@ -144,6 +144,10 @@ def decorator(target):
raise Exception("not a decoratable function")
spec = compat.inspect_getfullargspec(fn)
+ env = {}
+
+ spec = _update_argspec_defaults_into_env(spec, env)
+
names = tuple(spec[0]) + spec[1:3] + (fn.__name__,)
targ_name, fn_name = _unique_symbols(names, "target", "fn")
@@ -157,9 +161,9 @@ def %(name)s(%(args)s):
"""
% metadata
)
- decorated = _exec_code_in_env(
- code, {targ_name: target, fn_name: fn}, fn.__name__
- )
+ env.update({targ_name: target, fn_name: fn})
+
+ decorated = _exec_code_in_env(code, env, fn.__name__)
decorated.__defaults__ = getattr(fn, "im_func", fn).__defaults__
decorated.__wrapped__ = fn
return update_wrapper(decorated, fn)
@@ -167,6 +171,27 @@ def %(name)s(%(args)s):
return update_wrapper(decorate, target)
+def _update_argspec_defaults_into_env(spec, env):
+ """given a FullArgSpec, convert defaults to be symbol names in an env."""
+
+ if spec.defaults:
+ new_defaults = []
+ i = 0
+ for arg in spec.defaults:
+ if type(arg).__module__ not in ("builtins", "__builtin__"):
+ name = "x%d" % i
+ env[name] = arg
+ new_defaults.append(name)
+ i += 1
+ else:
+ new_defaults.append(arg)
+ elem = list(spec)
+ elem[3] = tuple(new_defaults)
+ return compat.FullArgSpec(*elem)
+ else:
+ return spec
+
+
def _exec_code_in_env(code, env, fn_name):
exec(code, env)
return env[fn_name]
diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py
index b4ac69d2d..73d767602 100644
--- a/test/dialect/postgresql/test_compiler.py
+++ b/test/dialect/postgresql/test_compiler.py
@@ -829,7 +829,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
)
m2 = MetaData()
- tbl2 = tbl.tometadata(m2)
+ tbl2 = tbl.to_metadata(m2)
self.assert_compile(
schema.CreateTable(tbl2),
"CREATE TABLE testtbl (room SERIAL NOT NULL, "
diff --git a/test/test_deprecations.py b/test/dialect/test_deprecations.py
index 5f8e79cba..b2ee708e2 100644
--- a/test/test_deprecations.py
+++ b/test/dialect/test_deprecations.py
@@ -1,13 +1,11 @@
-from sqlalchemy.testing import expect_deprecated_20
+from sqlalchemy import testing
from sqlalchemy.testing import fixtures
from sqlalchemy.util.compat import import_
-class DeprecationWarningsTest(fixtures.TestBase):
- __backend__ = False
-
+class DatabaseRemovedTest(fixtures.TestBase):
def test_deprecate_databases(self):
- with expect_deprecated_20(
+ with testing.expect_deprecated_20(
"The `database` package is deprecated and will be removed in v2.0 "
):
import_("sqlalchemy.databases")
diff --git a/test/orm/test_bind.py b/test/orm/test_bind.py
index bef06c390..2b7939edf 100644
--- a/test/orm/test_bind.py
+++ b/test/orm/test_bind.py
@@ -40,8 +40,8 @@ class BindIntegrationTest(_fixtures.FixtureTest):
# ensure tables are unbound
m2 = sa.MetaData()
- users_unbound = users.tometadata(m2)
- addresses_unbound = addresses.tometadata(m2)
+ users_unbound = users.to_metadata(m2)
+ addresses_unbound = addresses.to_metadata(m2)
mapper(Address, addresses_unbound)
mapper(
@@ -97,8 +97,8 @@ class BindIntegrationTest(_fixtures.FixtureTest):
# ensure tables are unbound
m2 = sa.MetaData()
- users_unbound = users.tometadata(m2)
- addresses_unbound = addresses.tometadata(m2)
+ users_unbound = users.to_metadata(m2)
+ addresses_unbound = addresses.to_metadata(m2)
mapper(Address, addresses_unbound)
mapper(
@@ -491,7 +491,7 @@ class SessionBindTest(fixtures.MappedTest):
test_table, Foo = cls.tables.test_table, cls.classes.Foo
meta = MetaData()
- test_table.tometadata(meta)
+ test_table.to_metadata(meta)
assert meta.tables["test_table"].bind is None
mapper(Foo, meta.tables["test_table"])
diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py
index c12543f82..28150d15e 100644
--- a/test/sql/test_compiler.py
+++ b/test/sql/test_compiler.py
@@ -4213,7 +4213,7 @@ class DDLTest(fixtures.TestBase, AssertsCompiledSQL):
schema.CreateTable(t), "CREATE TABLE t (x INTEGER, z INTEGER)"
)
m2 = MetaData()
- t2 = t.tometadata(m2)
+ t2 = t.to_metadata(m2)
self.assert_compile(
schema.CreateTable(t2), "CREATE TABLE t (x INTEGER, z INTEGER)"
)
diff --git a/test/sql/test_computed.py b/test/sql/test_computed.py
index 2999c621c..c7cb3dd11 100644
--- a/test/sql/test_computed.py
+++ b/test/sql/test_computed.py
@@ -57,7 +57,7 @@ class DDLComputedTest(fixtures.TestBase, AssertsCompiledSQL):
assert_raises_message(ArgumentError, text, fn, server_default="42")
assert_raises_message(ArgumentError, text, fn, server_onupdate="42")
- def test_tometadata(self):
+ def test_to_metadata(self):
comp1 = Computed("x + 2")
m = MetaData()
t = Table("t", m, Column("x", Integer), Column("y", Integer, comp1))
@@ -66,7 +66,7 @@ class DDLComputedTest(fixtures.TestBase, AssertsCompiledSQL):
is_(t.c.y.server_default, comp1)
m2 = MetaData()
- t2 = t.tometadata(m2)
+ t2 = t.to_metadata(m2)
comp2 = t2.c.y.server_default
is_not_(comp1, comp2)
diff --git a/test/sql/test_deprecations.py b/test/sql/test_deprecations.py
index 3cc9a06ed..16bd25b3f 100644
--- a/test/sql/test_deprecations.py
+++ b/test/sql/test_deprecations.py
@@ -44,6 +44,19 @@ from sqlalchemy.testing.schema import Column
from sqlalchemy.testing.schema import Table
+class ToMetaDataTest(fixtures.TestBase):
+ def test_deprecate_tometadata(self):
+ m1 = MetaData()
+ t1 = Table("t", m1, Column("q", Integer))
+
+ with testing.expect_deprecated(
+ r"Table.tometadata\(\) is renamed to Table.to_metadata\(\)"
+ ):
+ m2 = MetaData()
+ t2 = t1.tometadata(m2)
+ eq_(t2.name, "t")
+
+
class DeprecationWarningsTest(fixtures.TestBase, AssertsCompiledSQL):
__backend__ = True
diff --git a/test/sql/test_metadata.py b/test/sql/test_metadata.py
index 4351e562e..3303eac1d 100644
--- a/test/sql/test_metadata.py
+++ b/test/sql/test_metadata.py
@@ -804,9 +804,9 @@ class ToMetaDataTest(fixtures.TestBase, ComparesTables):
def test_to_metadata():
meta2 = MetaData()
- table_c = table.tometadata(meta2)
- table2_c = table2.tometadata(meta2)
- table3_c = table3.tometadata(meta2)
+ table_c = table.to_metadata(meta2)
+ table2_c = table2.to_metadata(meta2)
+ table3_c = table3.to_metadata(meta2)
return (table_c, table2_c, table3_c)
def test_pickle():
@@ -905,8 +905,8 @@ class ToMetaDataTest(fixtures.TestBase, ComparesTables):
assert b.c.y.references(a.c.x)
m2 = MetaData()
- b2 = b.tometadata(m2)
- a2 = a.tometadata(m2)
+ b2 = b.to_metadata(m2)
+ a2 = a.to_metadata(m2)
assert b2.c.y.references(a2.c.x)
def test_change_schema(self):
@@ -931,8 +931,8 @@ class ToMetaDataTest(fixtures.TestBase, ComparesTables):
)
meta2 = MetaData()
- table_c = table.tometadata(meta2, schema="someschema")
- table2_c = table2.tometadata(meta2, schema="someschema")
+ table_c = table.to_metadata(meta2, schema="someschema")
+ table2_c = table2.to_metadata(meta2, schema="someschema")
eq_(
str(table_c.join(table2_c).onclause),
@@ -967,8 +967,8 @@ class ToMetaDataTest(fixtures.TestBase, ComparesTables):
)
meta2 = MetaData()
- table_c = table.tometadata(meta2)
- table2_c = table2.tometadata(meta2)
+ table_c = table.to_metadata(meta2)
+ table2_c = table2.to_metadata(meta2)
eq_(
str(table_c.join(table2_c).onclause),
@@ -994,8 +994,8 @@ class ToMetaDataTest(fixtures.TestBase, ComparesTables):
schema="myschema",
)
- table2 = table.tometadata(table.metadata, name="newtable")
- table3 = table.tometadata(
+ table2 = table.to_metadata(table.metadata, name="newtable")
+ table3 = table.to_metadata(
table.metadata, schema="newschema", name="newtable"
)
@@ -1026,7 +1026,7 @@ class ToMetaDataTest(fixtures.TestBase, ComparesTables):
schema="myschema",
)
- table2 = table.tometadata(meta2, name="newtable")
+ table2 = table.to_metadata(meta2, name="newtable")
assert table.metadata is not table2.metadata
eq_((table.name, table2.name), ("mytable", "newtable"))
@@ -1046,7 +1046,7 @@ class ToMetaDataTest(fixtures.TestBase, ComparesTables):
Column("ref_id", ForeignKey("ref.id")),
)
- table2 = table.tometadata(table.metadata, name="newtable")
+ table2 = table.to_metadata(table.metadata, name="newtable")
assert table.metadata is table2.metadata
assert table2.c.ref_id.references(referenced.c.id)
assert table2.c.parent_id.references(table2.c.id)
@@ -1065,10 +1065,10 @@ class ToMetaDataTest(fixtures.TestBase, ComparesTables):
Column("ref_id", ForeignKey("ref.id")),
)
- table2 = table.tometadata(
+ table2 = table.to_metadata(
table.metadata, name="newtable", schema="newschema"
)
- ref2 = referenced.tometadata(table.metadata, schema="newschema")
+ ref2 = referenced.to_metadata(table.metadata, schema="newschema")
assert table.metadata is table2.metadata
assert table2.c.ref_id.references(ref2.c.id)
assert table2.c.parent_id.references(table2.c.id)
@@ -1077,12 +1077,12 @@ class ToMetaDataTest(fixtures.TestBase, ComparesTables):
m2 = MetaData()
existing_schema = t2.schema
if schema:
- t2c = t2.tometadata(
+ t2c = t2.to_metadata(
m2, schema=schema, referred_schema_fn=referred_schema_fn
)
eq_(t2c.schema, schema)
else:
- t2c = t2.tometadata(m2, referred_schema_fn=referred_schema_fn)
+ t2c = t2.to_metadata(m2, referred_schema_fn=referred_schema_fn)
eq_(t2c.schema, existing_schema)
eq_(list(t2c.c.y.foreign_keys)[0]._get_colspec(), expected)
@@ -1239,7 +1239,7 @@ class ToMetaDataTest(fixtures.TestBase, ComparesTables):
fkc.info["fkcinfo"] = True
m2 = MetaData()
- t2 = t.tometadata(m2)
+ t2 = t.to_metadata(m2)
m.info["minfo"] = False
fk.info["fkinfo"] = False
@@ -1279,7 +1279,7 @@ class ToMetaDataTest(fixtures.TestBase, ComparesTables):
)
meta2 = MetaData()
- table_c = table.tometadata(meta2)
+ table_c = table.to_metadata(meta2)
eq_(table.kwargs, {"mysql_engine": "InnoDB"})
@@ -1301,7 +1301,7 @@ class ToMetaDataTest(fixtures.TestBase, ComparesTables):
Index("multi-func", table.c.data1, func.abs(table.c.data2))
meta2 = MetaData()
- table_c = table.tometadata(meta2)
+ table_c = table.to_metadata(meta2)
def _get_key(i):
return (
@@ -1339,7 +1339,7 @@ class ToMetaDataTest(fixtures.TestBase, ComparesTables):
)
meta2 = MetaData()
- table_c = table.tometadata(meta2)
+ table_c = table.to_metadata(meta2)
def _get_key(i):
return (
@@ -1365,8 +1365,8 @@ class ToMetaDataTest(fixtures.TestBase, ComparesTables):
"mytable", meta2, Column("yourid", Integer, primary_key=True)
)
- table_c = table1.tometadata(meta2)
- table_d = table2.tometadata(meta2)
+ table_c = table1.to_metadata(meta2)
+ table_d = table2.to_metadata(meta2)
# d'oh!
assert table_c is table_d
@@ -1393,8 +1393,8 @@ class ToMetaDataTest(fixtures.TestBase, ComparesTables):
)
meta2 = MetaData(schema="someschema")
- table_c = table.tometadata(meta2, schema=None)
- table2_c = table2.tometadata(meta2, schema=None)
+ table_c = table.to_metadata(meta2, schema=None)
+ table2_c = table2.to_metadata(meta2, schema=None)
eq_(
str(table_c.join(table2_c).onclause),
@@ -1427,8 +1427,8 @@ class ToMetaDataTest(fixtures.TestBase, ComparesTables):
)
meta2 = MetaData()
- table_c = table.tometadata(meta2, schema=None)
- table2_c = table2.tometadata(meta2, schema=None)
+ table_c = table.to_metadata(meta2, schema=None)
+ table2_c = table2.to_metadata(meta2, schema=None)
eq_(
str(table_c.join(table2_c).onclause),
@@ -1446,7 +1446,7 @@ class ToMetaDataTest(fixtures.TestBase, ComparesTables):
m2 = MetaData()
- t2 = table.tometadata(m2)
+ t2 = table.to_metadata(m2)
eq_(
len(
@@ -1466,7 +1466,7 @@ class ToMetaDataTest(fixtures.TestBase, ComparesTables):
m2 = MetaData()
- t2 = table.tometadata(m2)
+ t2 = table.to_metadata(m2)
eq_(len(t2.indexes), 1)
@@ -2067,14 +2067,14 @@ class SchemaTypeTest(fixtures.TestBase):
t1 = Table("x", m, Column("y", type_), schema="z")
eq_(t1.c.y.type.schema, "z")
- def test_tometadata_copy_type(self):
+ def test_to_metadata_copy_type(self):
m1 = MetaData()
type_ = self.MyType()
t1 = Table("x", m1, Column("y", type_))
m2 = MetaData()
- t2 = t1.tometadata(m2)
+ t2 = t1.to_metadata(m2)
# metadata isn't set
is_(t2.c.y.type.metadata, None)
@@ -2082,7 +2082,7 @@ class SchemaTypeTest(fixtures.TestBase):
# our test type sets table, though
is_(t2.c.y.type.table, t2)
- def test_tometadata_copy_decorated(self):
+ def test_to_metadata_copy_decorated(self):
class MyDecorated(TypeDecorator):
impl = self.MyType
@@ -2092,40 +2092,40 @@ class SchemaTypeTest(fixtures.TestBase):
t1 = Table("x", m1, Column("y", type_))
m2 = MetaData()
- t2 = t1.tometadata(m2)
+ t2 = t1.to_metadata(m2)
eq_(t2.c.y.type.schema, "z")
- def test_tometadata_independent_schema(self):
+ def test_to_metadata_independent_schema(self):
m1 = MetaData()
type_ = self.MyType()
t1 = Table("x", m1, Column("y", type_))
m2 = MetaData()
- t2 = t1.tometadata(m2, schema="bar")
+ t2 = t1.to_metadata(m2, schema="bar")
eq_(t2.c.y.type.schema, None)
- def test_tometadata_inherit_schema(self):
+ def test_to_metadata_inherit_schema(self):
m1 = MetaData()
type_ = self.MyType(inherit_schema=True)
t1 = Table("x", m1, Column("y", type_))
m2 = MetaData()
- t2 = t1.tometadata(m2, schema="bar")
+ t2 = t1.to_metadata(m2, schema="bar")
eq_(t1.c.y.type.schema, None)
eq_(t2.c.y.type.schema, "bar")
- def test_tometadata_independent_events(self):
+ def test_to_metadata_independent_events(self):
m1 = MetaData()
type_ = self.MyType()
t1 = Table("x", m1, Column("y", type_))
m2 = MetaData()
- t2 = t1.tometadata(m2)
+ t2 = t1.to_metadata(m2)
t1.dispatch.before_create(t1, testing.db)
eq_(t1.c.y.type.evt_targets, (t1,))
@@ -2264,7 +2264,7 @@ class SchemaTypeTest(fixtures.TestBase):
1,
)
m2 = MetaData()
- t2 = t1.tometadata(m2)
+ t2 = t1.to_metadata(m2)
eq_(
len([c for c in t2.constraints if isinstance(c, CheckConstraint)]),
@@ -2284,7 +2284,7 @@ class SchemaTypeTest(fixtures.TestBase):
1,
)
m2 = MetaData()
- t2 = t1.tometadata(m2)
+ t2 = t1.to_metadata(m2)
eq_(
len([c for c in t2.constraints if isinstance(c, CheckConstraint)]),
@@ -3268,7 +3268,7 @@ class ConstraintTest(fixtures.TestBase):
):
assert True
- def test_tometadata_ok(self):
+ def test_to_metadata_ok(self):
m = MetaData()
t = Table("tbl", m, Column("a", Integer), Column("b", Integer))
@@ -3282,7 +3282,7 @@ class ConstraintTest(fixtures.TestBase):
m2 = MetaData()
- t3 = t.tometadata(m2)
+ t3 = t.to_metadata(m2)
eq_(len(t3.constraints), 4)
@@ -5290,5 +5290,5 @@ class CopyDialectOptionsTest(fixtures.TestBase):
self.check_dialect_options_(t1)
m2 = MetaData()
- t2 = t1.tometadata(m2) # make a copy
+ t2 = t1.to_metadata(m2) # make a copy
self.check_dialect_options_(t2)