-
Notifications
You must be signed in to change notification settings - Fork 8
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
How to work with composite field #4
Comments
Seems like it's a row decoder that you're describing here, so I'll assume that you meant
If I understood you correctly, it seems like a combination of "tuple" and "tuple-th" libraries could be of help, in particular, the It also seems like we may need to implement a more general utility than |
So assume the following queries with example1 :: HS.Statement Int64 Entry
example1 = HS.Statement sql encoder decoder False where
sql = "select id, name, phone from book where district_id=$1"
encoder = (HE.column.HE.nonNullable) HE.int8
decoder = HD.rowVector $ decodeEntry
example1_2 :: HS.Statement Int64 Entry
example1_2 = HS.Statement sql encoder decoder False where
sql = [hasql|
select a.id, b.id, b.name, b.phone
from a inner join book on b.a_id = a.id
left join c on d.id=b.district_id where a.id=$1 |]
encoder = (HE.column.HE.nonNullable) HE.int8
decoder = HD.rowVector $ (,,) <$> decodeA <*> decodeEntry <*> decodeB Here I was able to use the same function that converts columns With |
In my current project I have a decoder functions,
decodeEntity :: Result A
that decodes some columns, then I can write more complex decoder as:But when statement returns big tuple I can no longer reuse the same parser. Is there a way to achieve the same with
hasql-th
?The text was updated successfully, but these errors were encountered: