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

Function _populate_full

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

Source from the content-addressed store, hash-verified

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

Callers 1

_instanceFunction · 0.85

Calls 2

popMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected