| 4830 | argnames="paramname, value", |
| 4831 | ) |
| 4832 | def test_merge_column(self, paramname, value): |
| 4833 | args = [] |
| 4834 | params = {} |
| 4835 | if paramname == "type" or isinstance( |
| 4836 | value, (Computed, Sequence, Identity) |
| 4837 | ): |
| 4838 | args.append(value) |
| 4839 | else: |
| 4840 | params[paramname] = value |
| 4841 | |
| 4842 | source = Column(*args, **params) |
| 4843 | |
| 4844 | target = Column() |
| 4845 | |
| 4846 | source._merge(target) |
| 4847 | |
| 4848 | target_copy = target._copy() |
| 4849 | for col in ( |
| 4850 | target, |
| 4851 | target_copy, |
| 4852 | ): |
| 4853 | if isinstance(value, (Computed, Identity)): |
| 4854 | default = col.server_default |
| 4855 | assert isinstance(default, type(value)) |
| 4856 | is_(default.column, col) |
| 4857 | elif isinstance(value, Sequence): |
| 4858 | default = col.default |
| 4859 | |
| 4860 | # TODO: sequence mutated in place |
| 4861 | is_(default.column, target_copy) |
| 4862 | |
| 4863 | assert isinstance(default, type(value)) |
| 4864 | |
| 4865 | elif paramname in ( |
| 4866 | "default", |
| 4867 | "onupdate", |
| 4868 | "server_default", |
| 4869 | "server_onupdate", |
| 4870 | ): |
| 4871 | default = getattr(col, paramname) |
| 4872 | is_(default.arg, value) |
| 4873 | |
| 4874 | # TODO: _copy() seems to note that it isn't copying |
| 4875 | # server defaults or defaults outside of Computed, Identity, |
| 4876 | # so here it's getting mutated in place. this is a bug |
| 4877 | is_(default.column, target_copy) |
| 4878 | |
| 4879 | elif paramname in ("info",): |
| 4880 | eq_(col.info, value) |
| 4881 | elif paramname == "type": |
| 4882 | assert type(col.type) is type(value) |
| 4883 | |
| 4884 | if isinstance(col.type, Enum): |
| 4885 | col.name = "data" |
| 4886 | t = Table("t", MetaData(), col) |
| 4887 | assert CheckConstraint in [type(c) for c in t.constraints] |
| 4888 | else: |
| 4889 | is_(getattr(col, paramname), value) |