Add the given list of model field names to the set of fields to exclude from loading from the database when automatic column selection is done. Add the new field names to any existing field names that are deferred (or removed from any existing field names that are ma
(self, field_names)
| 2498 | self.deferred_loading = (frozenset(), True) |
| 2499 | |
| 2500 | def add_deferred_loading(self, field_names): |
| 2501 | """ |
| 2502 | Add the given list of model field names to the set of fields to |
| 2503 | exclude from loading from the database when automatic column selection |
| 2504 | is done. Add the new field names to any existing field names that |
| 2505 | are deferred (or removed from any existing field names that are marked |
| 2506 | as the only ones for immediate loading). |
| 2507 | """ |
| 2508 | # Fields on related models are stored in the literal double-underscore |
| 2509 | # format, so that we can use a set datastructure. We do the foo__bar |
| 2510 | # splitting and handling when computing the SQL column names (as part |
| 2511 | # of get_columns()). |
| 2512 | existing, defer = self.deferred_loading |
| 2513 | if defer: |
| 2514 | # Add to existing deferred names. |
| 2515 | self.deferred_loading = existing.union(field_names), True |
| 2516 | else: |
| 2517 | # Remove names from the set of any existing "immediate load" names. |
| 2518 | if new_existing := existing.difference(field_names): |
| 2519 | self.deferred_loading = new_existing, False |
| 2520 | else: |
| 2521 | self.clear_deferred_loading() |
| 2522 | if new_only := set(field_names).difference(existing): |
| 2523 | self.deferred_loading = new_only, True |
| 2524 | |
| 2525 | def add_immediate_loading(self, field_names): |
| 2526 | """ |
no test coverage detected