MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _populate_full

Function _populate_full

lib/sqlalchemy/orm/loading.py:1336–1390  ·  view source on GitHub ↗
(
    context,
    row,
    state,
    dict_,
    isnew,
    load_path,
    loaded_instance,
    populate_existing,
    populators,
)

Source from the content-addressed store, hash-verified

1334
1335
1336def _populate_full(
1337 context,
1338 row,
1339 state,
1340 dict_,
1341 isnew,
1342 load_path,
1343 loaded_instance,
1344 populate_existing,
1345 populators,
1346):
1347 if isnew:
1348 # first time we are seeing a row with this identity.
1349 state.runid = context.runid
1350
1351 for key, getter in populators["quick"]:
1352 dict_[key] = getter(row)
1353 if populate_existing:
1354 for key, set_callable in populators["expire"]:
1355 dict_.pop(key, None)
1356 if set_callable:
1357 state.expired_attributes.add(key)
1358 else:
1359 for key, set_callable in populators["expire"]:
1360 if set_callable:
1361 state.expired_attributes.add(key)
1362
1363 for key, populator in populators["new"]:
1364 populator(state, dict_, row)
1365
1366 elif load_path != state.load_path:
1367 # new load path, e.g. object is present in more than one
1368 # column position in a series of rows
1369 state.load_path = load_path
1370
1371 # if we have data, and the data isn't in the dict, OK, let's put
1372 # it in.
1373 for key, getter in populators["quick"]:
1374 if key not in dict_:
1375 dict_[key] = getter(row)
1376
1377 # otherwise treat like an "already seen" row
1378 for key, populator in populators["existing"]:
1379 populator(state, dict_, row)
1380 # TODO: allow "existing" populator to know this is
1381 # a new path for the state:
1382 # populator(state, dict_, row, new_path=True)
1383
1384 else:
1385 # have already seen rows with this identity in this same path.
1386 for key, populator in populators["existing"]:
1387 populator(state, dict_, row)
1388
1389 # TODO: same path
1390 # populator(state, dict_, row, new_path=False)
1391
1392
1393def _populate_partial(

Callers 1

_instanceFunction · 0.85

Calls 2

popMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected