MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / _merge

Method _merge

lib/sqlalchemy/sql/schema.py:2536–2619  ·  view source on GitHub ↗

merge the elements of another column into this one. this is used by ORM pep-593 merge and will likely need a lot of fixes.

(self, other: Column[Any])

Source from the content-addressed store, hash-verified

2534 return self._schema_item_copy(c)
2535
2536 def _merge(self, other: Column[Any]) -> None:
2537 """merge the elements of another column into this one.
2538
2539 this is used by ORM pep-593 merge and will likely need a lot
2540 of fixes.
2541
2542
2543 """
2544
2545 if self.primary_key:
2546 other.primary_key = True
2547
2548 if self.autoincrement != "auto" and other.autoincrement == "auto":
2549 other.autoincrement = self.autoincrement
2550
2551 if self.system:
2552 other.system = self.system
2553
2554 if self.info:
2555 other.info.update(self.info)
2556
2557 type_ = self.type
2558 if not type_._isnull and other.type._isnull:
2559 if isinstance(type_, SchemaEventTarget):
2560 type_ = type_.copy()
2561
2562 other.type = type_
2563
2564 if isinstance(type_, SchemaEventTarget):
2565 type_._set_parent_with_dispatch(other)
2566
2567 for impl in type_._variant_mapping.values():
2568 if isinstance(impl, SchemaEventTarget):
2569 impl._set_parent_with_dispatch(other)
2570
2571 if (
2572 self._user_defined_nullable is not NULL_UNSPECIFIED
2573 and other._user_defined_nullable is NULL_UNSPECIFIED
2574 ):
2575 other.nullable = self.nullable
2576 other._user_defined_nullable = self._user_defined_nullable
2577
2578 if self.default is not None and other.default is None:
2579 new_default = self.default._copy()
2580 new_default._set_parent(other)
2581
2582 if self.server_default and other.server_default is None:
2583 new_server_default = self.server_default
2584 if isinstance(new_server_default, FetchedValue):
2585 new_server_default = new_server_default._copy()
2586 new_server_default._set_parent(other)
2587 else:
2588 other.server_default = new_server_default
2589
2590 if self.server_onupdate and other.server_onupdate is None:
2591 new_server_onupdate = self.server_onupdate
2592 new_server_onupdate = new_server_onupdate._copy()
2593 new_server_onupdate._set_parent(other)

Calls 6

updateMethod · 0.45
copyMethod · 0.45
valuesMethod · 0.45
_copyMethod · 0.45
_set_parentMethod · 0.45