args = []
for c in self.columns:
- args.append(c.copy(schema=schema))
+ args.append(c._copy(schema=schema))
table = Table(
name,
metadata,
schema if referred_schema == self.schema else None
)
table.append_constraint(
- c.copy(schema=fk_constraint_schema, target_table=table)
+ c._copy(schema=fk_constraint_schema, target_table=table)
)
elif not c._type_bound:
# skip unique constraints that would be generated
continue
table.append_constraint(
- c.copy(schema=schema, target_table=table)
+ c._copy(schema=schema, target_table=table)
)
for index in self.indexes:
# skip indexes that would be generated
else:
event.listen(self, "after_parent_attach", fn)
+ @util.deprecated(
+ "1.4",
+ "The :meth:`_schema.Column.copy` method is deprecated "
+ "and will be removed in a future release.",
+ )
def copy(self, **kw):
+ return self._copy(**kw)
+
+ def _copy(self, **kw):
"""Create a copy of this ``Column``, uninitialized.
This is used in :meth:`_schema.Table.to_metadata`.
# Constraint objects plus non-constraint-bound ForeignKey objects
args = [
- c.copy(**kw) for c in self.constraints if not c._type_bound
- ] + [c.copy(**kw) for c in self.foreign_keys if not c.constraint]
+ c._copy(**kw) for c in self.constraints if not c._type_bound
+ ] + [c._copy(**kw) for c in self.foreign_keys if not c.constraint]
# ticket #5276
column_kwargs = {}
server_onupdate = self.server_onupdate
if isinstance(server_default, (Computed, Identity)):
server_default = server_onupdate = None
- args.append(self.server_default.copy(**kw))
+ args.append(self.server_default._copy(**kw))
type_ = self.type
if isinstance(type_, SchemaEventTarget):
def __repr__(self):
return "ForeignKey(%r)" % self._get_colspec()
+ @util.deprecated(
+ "1.4",
+ "The :meth:`_schema.ForeignKey.copy` method is deprecated "
+ "and will be removed in a future release.",
+ )
def copy(self, schema=None):
+ return self._copy(schema)
+
+ def _copy(self, schema=None):
"""Produce a copy of this :class:`_schema.ForeignKey` object.
The new :class:`_schema.ForeignKey` will not be bound
self.parent = parent
parent.constraints.add(self)
+ @util.deprecated(
+ "1.4",
+ "The :meth:`_schema.Constraint.copy` method is deprecated "
+ "and will be removed in a future release.",
+ )
def copy(self, **kw):
+ return self._copy(**kw)
+
+ def _copy(self, **kw):
raise NotImplementedError()
def __contains__(self, x):
return x in self.columns
+ @util.deprecated(
+ "1.4",
+ "The :meth:`_schema.ColumnCollectionConstraint.copy` method "
+ "is deprecated and will be removed in a future release.",
+ )
def copy(self, target_table=None, **kw):
+ return self._copy(target_table, **kw)
+
+ def _copy(self, target_table=None, **kw):
# ticket #5276
constraint_kwargs = {}
for dialect_name in self.dialect_options:
def is_column_level(self):
return not isinstance(self.parent, Table)
+ @util.deprecated(
+ "1.4",
+ "The :meth:`_schema.CheckConstraint.copy` method is deprecated "
+ "and will be removed in a future release.",
+ )
def copy(self, target_table=None, **kw):
+ return self._copy(target_table, **kw)
+
+ def _copy(self, target_table=None, **kw):
if target_table is not None:
# note that target_table is None for the copy process of
# a column-bound CheckConstraint, so this path is not reached
self._validate_dest_table(table)
+ @util.deprecated(
+ "1.4",
+ "The :meth:`_schema.ForeignKeyConstraint.copy` method is deprecated "
+ "and will be removed in a future release.",
+ )
def copy(self, schema=None, target_table=None, **kw):
+ return self._copy(target_table, **kw)
+
+ def _copy(self, schema=None, target_table=None, **kw):
fkc = ForeignKeyConstraint(
[x.parent.key for x in self.elements],
[
def _as_for_update(self, for_update):
return self
+ @util.deprecated(
+ "1.4",
+ "The :meth:`_schema.Computed.copy` method is deprecated "
+ "and will be removed in a future release.",
+ )
def copy(self, target_table=None, **kw):
+ return self._copy(target_table, **kw)
+
+ def _copy(self, target_table=None, **kw):
sqltext = _copy_expression(
self.sqltext,
self.column.table if self.column is not None else None,
def _as_for_update(self, for_update):
return self
+ @util.deprecated(
+ "1.4",
+ "The :meth:`_schema.Identity.copy` method is deprecated "
+ "and will be removed in a future release.",
+ )
def copy(self, **kw):
+ return self._copy(**kw)
+
+ def _copy(self, **kw):
i = Identity(
always=self.always,
on_null=self.on_null,
),
Column("bar", Integer(), info={"foo": "bar"}),
]:
- c2 = col.copy()
+ c2 = col._copy()
for attr in (
"name",
"type",
self.widget = kw.pop("widget", None)
super(MyColumn, self).__init__(*args, **kw)
- def copy(self, *arg, **kw):
- c = super(MyColumn, self).copy(*arg, **kw)
+ def _copy(self, *arg, **kw):
+ c = super(MyColumn, self)._copy(*arg, **kw)
c.widget = self.widget
return c
c1 = MyColumn("foo", Integer, widget="x")
- c2 = c1.copy()
+ c2 = c1._copy()
assert isinstance(c2, MyColumn)
eq_(c2.widget, "x")
c1 = Column("foo", String())
m = MetaData()
for i in range(3):
- cx = c1.copy()
+ cx = c1._copy()
# as of 0.7, these events no longer copy. its expected
# that listeners will be re-established from the
# natural construction of things.
fk2 = ForeignKeyConstraint((c1,), (c2,), **kw)
t1.append_constraint(fk2)
- fk1c = fk1.copy()
- fk2c = fk2.copy()
+ fk1c = fk1._copy()
+ fk2c = fk2._copy()
for k in kw:
eq_(getattr(fk1c, k), kw[k])
deferrable=True,
_create_rule=r,
)
- c2 = c.copy()
+ c2 = c._copy()
eq_(c2.name, "name")
eq_(str(c2.sqltext), "foo bar")
eq_(c2.initially, True)
type_ = self.WrapEnum("a", "b", "c", name="foo")
y = Column("y", type_)
- y_copy = y.copy()
+ y_copy = y._copy()
t1 = Table("x", m, y_copy)
is_true(y_copy.type._create_events)
type_ = self.WrapEnum("a", "b", "c", name="foo", native_enum=False)
y = Column("y", type_)
- y_copy = y.copy()
+ y_copy = y._copy()
t1 = Table("x", m, y_copy)
is_true(y_copy.type._create_events)
create_constraint=False,
)
y = Column("y", type_)
- y_copy = y.copy()
+ y_copy = y._copy()
Table("x", m, y_copy)
is_false(y_copy.type.create_constraint)
type_ = self.WrapBoolean()
y = Column("y", type_)
- y_copy = y.copy()
+ y_copy = y._copy()
Table("x", m, y_copy)
is_true(y_copy.type._create_events)
type_ = self.WrapBoolean(create_constraint=False)
y = Column("y", type_)
- y_copy = y.copy()
+ y_copy = y._copy()
Table("x", m, y_copy)
is_false(y_copy.type.create_constraint)
def test_copy_doesnt_reference(self):
t1, t2, t3 = self._single_fixture()
- a2 = t2.c.a.copy()
+ a2 = t2.c.a._copy()
assert not a2.references(t1.c.a)
assert not a2.references(t1.c.b)
m = MetaData()
t = Table("tbl", m, Column("a", Integer), Column("b", Integer))
ck = CheckConstraint(t.c.a > 5)
- ck2 = ck.copy()
+ ck2 = ck._copy()
assert ck in t.constraints
assert ck2 not in t.constraints