MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / merge_result

Method merge_result

lib/sqlalchemy/orm/query.py:3057–3089  ·  view source on GitHub ↗

Merge a result into this :class:`_query.Query` object's Session. Given an iterator returned by a :class:`_query.Query` of the same structure as this one, return an identical iterator of results, with all mapped instances merged into the session using :meth:`.Session.

(
        self,
        iterator: Union[
            FrozenResult[Any], Iterable[Sequence[Any]], Iterable[object]
        ],
        load: bool = True,
    )

Source from the content-addressed store, hash-verified

3055 enable_warnings=False, # warnings occur via loading.merge_result
3056 )
3057 def merge_result(
3058 self,
3059 iterator: Union[
3060 FrozenResult[Any], Iterable[Sequence[Any]], Iterable[object]
3061 ],
3062 load: bool = True,
3063 ) -> Union[FrozenResult[Any], Iterable[Any]]:
3064 """Merge a result into this :class:`_query.Query` object's Session.
3065
3066 Given an iterator returned by a :class:`_query.Query`
3067 of the same structure
3068 as this one, return an identical iterator of results, with all mapped
3069 instances merged into the session using :meth:`.Session.merge`. This
3070 is an optimized method which will merge all mapped instances,
3071 preserving the structure of the result rows and unmapped columns with
3072 less method overhead than that of calling :meth:`.Session.merge`
3073 explicitly for each value.
3074
3075 The structure of the results is determined based on the column list of
3076 this :class:`_query.Query` - if these do not correspond,
3077 unchecked errors
3078 will occur.
3079
3080 The 'load' argument is the same as that of :meth:`.Session.merge`.
3081
3082 For an example of how :meth:`_query.Query.merge_result` is used, see
3083 the source code for the example :ref:`examples_caching`, where
3084 :meth:`_query.Query.merge_result` is used to efficiently restore state
3085 from a cache back into a target :class:`.Session`.
3086
3087 """
3088
3089 return loading.merge_result(self, iterator, load)
3090
3091 def exists(self) -> Exists:
3092 """A convenience method that turns a query into an EXISTS subquery

Callers 5

test_single_entityMethod · 0.80
test_single_columnMethod · 0.80
test_none_entityMethod · 0.80

Calls

no outgoing calls

Tested by 5

test_single_entityMethod · 0.64
test_single_columnMethod · 0.64
test_none_entityMethod · 0.64