-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
decode joined rows #984
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what is the easiest way to decode joined rows?
select s.*, c.* from services s inner join catalogs c on s.catalog_id=c.id
I tried to decode it to
case class ServiceWithDetails(service: Service, catalog: Catalog)
, but did not succeed. No, actually I did it with map and manually filled ServiceWithDetails class and inner Service and Catalog , but it is so ugly looking after using slick that I thought there was a more elegant way to do it.
one way i found is convert table data to json in select statement:
select to_json(s.*), to_json(c.*) from services s inner join catalogs c on s.catalog_id=c.id
and decode it
(json[Service] *: json[Catalog]).to[ServiceWithDetails]
that works but with one little problem. the fields of case classes have to be in snake case to properly map.
This example is very simple. In general i have 3-10 table joins and map manually (fill every field of case class) seems hard and a waste of time.
Are there other methods?
The text was updated successfully, but these errors were encountered: