The spread operator (...) in a .select() query allows you to include all fields from a related table. The resulting type depends on the relationship type and the PostgREST version.
One-to-One or Many-to-One
The spread operator returns the object properties directly within the parent object.
Many-to-Many (PostgREST v13+)
If PostgrestVersion is 13 or higher and you spread over a many-to-many relationship, the library uses SpreadOnManyEnabled logic. Instead of returning an array of objects, it converts the fields into correlated arrays.
For example, if spreading a many-to-many relation that would normally return [{a: 1, b: 2}, {a: 3, b: 4}], the spread result becomes { a: [1, 3], b: [2, 4] }.
Errors
If you attempt to spread a relationship that is not many-to-one or one-to-one, you will receive a SelectQueryError:
"<RelationName>" and "<TargetName>" do not form a many-to-one or one-to-one relationship spread not possible.