MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / add

Method add

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

Source from the content-addressed store, hash-verified

2314 """
2315
2316 def add( # type: ignore[override]
2317 self,
2318 column: _NAMEDCOL,
2319 key: Optional[str] = None,
2320 *,
2321 index: Optional[int] = None,
2322 ) -> None:
2323 if key is not None and column.key != key:
2324 raise exc.ArgumentError(
2325 "DedupeColumnCollection requires columns be under "
2326 "the same key as their .key"
2327 )
2328 key = column.key
2329
2330 if key is None:
2331 raise exc.ArgumentError(
2332 "Can't add unnamed column to column collection"
2333 )
2334
2335 if key in self._index:
2336 existing = self._index[key][1]
2337
2338 if existing is column:
2339 return
2340
2341 self.replace(column, index=index)
2342
2343 # pop out memoized proxy_set as this
2344 # operation may very well be occurring
2345 # in a _make_proxy operation
2346 util.memoized_property.reset(column, "proxy_set")
2347 else:
2348 self._append_new_column(key, column, index=index)
2349
2350 def _append_new_column(
2351 self, key: str, named_column: _NAMEDCOL, *, index: Optional[int] = None

Callers 15

test_dupes_add_dedupeMethod · 0.95
test_replaceMethod · 0.95
test_replace_no_matchMethod · 0.95
test_dupes_extendMethod · 0.95
add_is_dependent_onMethod · 0.45
_make_proxyMethod · 0.45
_set_parentMethod · 0.45
_set_tableMethod · 0.45

Calls 3

replaceMethod · 0.95
_append_new_columnMethod · 0.95
resetMethod · 0.45