def map_many(self, *rows: typing.Mapping[str, typing.Any]):
"""
Maps many records to one row.
This will group the records by the primary key of the main query table, then add additional
columns as appropriate.
"""
# this assumes that the rows come in grouped by PK on the left
# also fuck right joins
# get the first row and construct the first table row using map_columns
# this will also map any extra relationship data there
first_row = rows[0]
tbl_row = self.map_columns(first_row)
# loop over every "extra" rows
# and update the relationship data in the table
for runon_row in rows[1:]:
tbl_row._update_relationships(runon_row)
pass
return tbl_row
# Helper methods for natural builder-style queries
评论列表
文章目录