(self, context, key, _instance, populators)
| 2917 | ) |
| 2918 | |
| 2919 | def _create_scalar_loader(self, context, key, _instance, populators): |
| 2920 | def load_scalar_from_joined_new_row(state, dict_, row): |
| 2921 | # set a scalar object instance directly on the parent |
| 2922 | # object, bypassing InstrumentedAttribute event handlers. |
| 2923 | dict_[key] = _instance(row) |
| 2924 | |
| 2925 | def load_scalar_from_joined_existing_row(state, dict_, row): |
| 2926 | # call _instance on the row, even though the object has |
| 2927 | # been created, so that we further descend into properties |
| 2928 | existing = _instance(row) |
| 2929 | |
| 2930 | # conflicting value already loaded, this shouldn't happen |
| 2931 | if key in dict_: |
| 2932 | if existing is not dict_[key]: |
| 2933 | util.warn( |
| 2934 | "Multiple rows returned with " |
| 2935 | "uselist=False for eagerly-loaded attribute '%s' " |
| 2936 | % self |
| 2937 | ) |
| 2938 | else: |
| 2939 | # this case is when one row has multiple loads of the |
| 2940 | # same entity (e.g. via aliasing), one has an attribute |
| 2941 | # that the other doesn't. |
| 2942 | dict_[key] = existing |
| 2943 | |
| 2944 | def load_scalar_from_joined_exec(state, dict_, row): |
| 2945 | _instance(row) |
| 2946 | |
| 2947 | populators["new"].append((self.key, load_scalar_from_joined_new_row)) |
| 2948 | populators["existing"].append( |
| 2949 | (self.key, load_scalar_from_joined_existing_row) |
| 2950 | ) |
| 2951 | if context.invoke_all_eagers: |
| 2952 | populators["eager"].append( |
| 2953 | (self.key, load_scalar_from_joined_exec) |
| 2954 | ) |
| 2955 | |
| 2956 | |
| 2957 | @log.class_logger |
no test coverage detected