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

Method add

lib/sqlalchemy/sql/base.py:2040–2068  ·  view source on GitHub ↗
(  # type: ignore[override]
        self, column: _NAMEDCOL, key: Optional[str] = None
    )

Source from the content-addressed store, hash-verified

2038 """
2039
2040 def add( # type: ignore[override]
2041 self, column: _NAMEDCOL, key: Optional[str] = None
2042 ) -> None:
2043 if key is not None and column.key != key:
2044 raise exc.ArgumentError(
2045 "DedupeColumnCollection requires columns be under "
2046 "the same key as their .key"
2047 )
2048 key = column.key
2049
2050 if key is None:
2051 raise exc.ArgumentError(
2052 "Can't add unnamed column to column collection"
2053 )
2054
2055 if key in self._index:
2056 existing = self._index[key][1]
2057
2058 if existing is column:
2059 return
2060
2061 self.replace(column)
2062
2063 # pop out memoized proxy_set as this
2064 # operation may very well be occurring
2065 # in a _make_proxy operation
2066 util.memoized_property.reset(column, "proxy_set")
2067 else:
2068 self._append_new_column(key, column)
2069
2070 def _append_new_column(self, key: str, named_column: _NAMEDCOL) -> None:
2071 l = len(self._collection)

Calls 3

replaceMethod · 0.95
_append_new_columnMethod · 0.95
resetMethod · 0.45