(
self, our_states, query_info, q, context, execution_options, chunksize
)
| 3463 | state.get_impl(self.key).set_committed_value(state, dict_, None) |
| 3464 | |
| 3465 | def _load_via_parent( |
| 3466 | self, our_states, query_info, q, context, execution_options, chunksize |
| 3467 | ): |
| 3468 | uselist = self.uselist |
| 3469 | n_pk = query_info.n_pk |
| 3470 | _empty_result = () if uselist else None |
| 3471 | |
| 3472 | while our_states: |
| 3473 | chunk = our_states[0:chunksize] |
| 3474 | our_states = our_states[chunksize:] |
| 3475 | |
| 3476 | primary_keys = [ |
| 3477 | key[0] if query_info.zero_idx else key |
| 3478 | for key, state, state_dict, overwrite in chunk |
| 3479 | ] |
| 3480 | |
| 3481 | result = context.session.execute( |
| 3482 | q, |
| 3483 | params={"primary_keys": primary_keys}, |
| 3484 | execution_options=execution_options, |
| 3485 | ) |
| 3486 | if result.context is not None and result.context.requires_uniquing: |
| 3487 | rows = result.unique() |
| 3488 | else: |
| 3489 | rows = result._raw_all_tuples() |
| 3490 | data = collections.defaultdict(list) |
| 3491 | for row in rows: |
| 3492 | data[row[:n_pk]].append(row[n_pk]) |
| 3493 | |
| 3494 | for key, state, state_dict, overwrite in chunk: |
| 3495 | if not overwrite and self.key in state_dict: |
| 3496 | continue |
| 3497 | |
| 3498 | collection = data.get(key, _empty_result) |
| 3499 | |
| 3500 | if not uselist and collection: |
| 3501 | if len(collection) > 1: |
| 3502 | util.warn( |
| 3503 | "Multiple rows returned with " |
| 3504 | "uselist=False for eagerly-loaded " |
| 3505 | "attribute '%s' " % self |
| 3506 | ) |
| 3507 | state.get_impl(self.key).set_committed_value( |
| 3508 | state, state_dict, collection[0] |
| 3509 | ) |
| 3510 | else: |
| 3511 | # note that empty tuple set on uselist=False sets the |
| 3512 | # value to None |
| 3513 | state.get_impl(self.key).set_committed_value( |
| 3514 | state, state_dict, collection |
| 3515 | ) |
| 3516 | |
| 3517 | |
| 3518 | def _single_parent_validator(desc, prop): |
no test coverage detected