--- /dev/null
+.. change::
+ :tags: change, sql
+
+ :class:`_schema.Table` parameter ``mustexist`` has been renamed
+ to :paramref:`_schema.Table.must_exist` and will now warn when used.
('column_reflect', listen_for_reflect)
])
- :param mustexist: When ``True``, indicates that this Table must already
+ :param must_exist: When ``True``, indicates that this Table must already
be present in the given :class:`_schema.MetaData` collection, else
an exception is raised.
else:
return (self,)
+ @util.deprecated_params(
+ mustexist=(
+ "1.4",
+ "Deprecated alias of :paramref:`_schema.Table.must_exist`",
+ )
+ )
def __new__(cls, *args, **kw):
if not args:
# python3k pickle seems to call this
msg = "keep_existing and extend_existing are mutually exclusive."
raise exc.ArgumentError(msg)
- mustexist = kw.pop("mustexist", False)
+ must_exist = kw.pop("must_exist", kw.pop("mustexist", False))
key = _get_table_key(name, schema)
if key in metadata.tables:
if not keep_existing and not extend_existing and bool(args):
table._init_existing(*args, **kw)
return table
else:
- if mustexist:
+ if must_exist:
raise exc.InvalidRequestError("Table '%s' not defined" % (key))
table = object.__new__(cls)
table.dispatch.before_parent_attach(table, metadata)
addresses = Table(
"email_addresses", meta2, autoload=True, schema="test_schema"
)
- users = Table("users", meta2, mustexist=True, schema="test_schema")
+ users = Table("users", meta2, must_exist=True, schema="test_schema")
j = join(users, addresses)
self.assert_(
(users.c.user_id == addresses.c.remote_user_id).compare(j.onclause)
self.assert_compile(
stmt, "UPDATE foo SET bar=%s LIMIT 10", dialect="mysql"
)
+
+
+class TableDeprecationTest(fixtures.TestBase):
+ def test_mustexists(self):
+ with testing.expect_deprecated("Deprecated alias of .*must_exist"):
+
+ with testing.expect_raises_message(
+ exc.InvalidRequestError, "Table 'foo' not defined"
+ ):
+ Table("foo", MetaData(), mustexist=True)
assert not t2.c.x.nullable
assert not t1.c.x.nullable
+ def test_must_exist(self):
+ with testing.expect_raises_message(
+ exc.InvalidRequestError, "Table 'foo' not defined"
+ ):
+ Table("foo", MetaData(), must_exist=True)
+
class PKAutoIncrementTest(fixtures.TestBase):
def test_multi_integer_no_autoinc(self):