Return a new :class:`.CursorResult` that "horizontally splices" together the rows of this :class:`.CursorResult` with that of another :class:`.CursorResult`. .. tip:: This method is for the benefit of the SQLAlchemy ORM and is not intended for general use.
(self, other: CursorResult[Any])
| 1965 | return self.context.returned_default_rows |
| 1966 | |
| 1967 | def splice_horizontally(self, other: CursorResult[Any]) -> Self: |
| 1968 | """Return a new :class:`.CursorResult` that "horizontally splices" |
| 1969 | together the rows of this :class:`.CursorResult` with that of another |
| 1970 | :class:`.CursorResult`. |
| 1971 | |
| 1972 | .. tip:: This method is for the benefit of the SQLAlchemy ORM and is |
| 1973 | not intended for general use. |
| 1974 | |
| 1975 | "horizontally splices" means that for each row in the first and second |
| 1976 | result sets, a new row that concatenates the two rows together is |
| 1977 | produced, which then becomes the new row. The incoming |
| 1978 | :class:`.CursorResult` must have the identical number of rows. It is |
| 1979 | typically expected that the two result sets come from the same sort |
| 1980 | order as well, as the result rows are spliced together based on their |
| 1981 | position in the result. |
| 1982 | |
| 1983 | The expected use case here is so that multiple INSERT..RETURNING |
| 1984 | statements (which definitely need to be sorted) against different |
| 1985 | tables can produce a single result that looks like a JOIN of those two |
| 1986 | tables. |
| 1987 | |
| 1988 | E.g.:: |
| 1989 | |
| 1990 | r1 = connection.execute( |
| 1991 | users.insert().returning( |
| 1992 | users.c.user_name, users.c.user_id, sort_by_parameter_order=True |
| 1993 | ), |
| 1994 | user_values, |
| 1995 | ) |
| 1996 | |
| 1997 | r2 = connection.execute( |
| 1998 | addresses.insert().returning( |
| 1999 | addresses.c.address_id, |
| 2000 | addresses.c.address, |
| 2001 | addresses.c.user_id, |
| 2002 | sort_by_parameter_order=True, |
| 2003 | ), |
| 2004 | address_values, |
| 2005 | ) |
| 2006 | |
| 2007 | rows = r1.splice_horizontally(r2).all() |
| 2008 | assert rows == [ |
| 2009 | ("john", 1, 1, "foo@bar.com", 1), |
| 2010 | ("jack", 2, 2, "bar@bat.com", 2), |
| 2011 | ] |
| 2012 | |
| 2013 | .. versionadded:: 2.0 |
| 2014 | |
| 2015 | .. seealso:: |
| 2016 | |
| 2017 | :meth:`.CursorResult.splice_vertically` |
| 2018 | |
| 2019 | |
| 2020 | """ # noqa: E501 |
| 2021 | |
| 2022 | clone = self._generate() |
| 2023 | assert clone is self # just to note |
| 2024 | assert isinstance(other._metadata, CursorResultMetaData) |