Skip to content
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

Is it possible to nest multiple SqlRows into one? #138

Open
Eugleo opened this issue May 7, 2020 · 2 comments
Open

Is it possible to nest multiple SqlRows into one? #138

Eugleo opened this issue May 7, 2020 · 2 comments
Labels
enhancement Issue suggests new or improved functionality.
Milestone

Comments

@Eugleo
Copy link

Eugleo commented May 7, 2020

I don't want to put IDs into my datatypes. I'd prefer to have a WithID wrapper type similar to the following:

data WithID a = WithID RowID a

and then do something like

instance SqlRow a => SqlRow (WithID a)

which would roughly mean "expand the a into a row and prepend the RowID from WithID. However, it seems to me that a here has to be an SqlType. Is there any way to do what I want?

Context: Let's say I have a type Comment. When the user makes a new Comment, I receive a Comment from the frontend. I store this Comment in the database, and only now it is given an ID. Now, whenever the user views all of his comments, I send WithID Comment to the frontend. As I'd like to avoid having two different datatypes (CommentWithoutID for frontend->db, and CommentWithID for db->frontend), I'm trying to do it with the wrapper instead.

@valderman
Copy link
Owner

This is not currently possible, but it's a good idea and we really should support it. There's no technical reason not to, as far as I can see.

@valderman valderman added this to the 0.5.2 milestone May 13, 2020
@valderman valderman added the enhancement Issue suggests new or improved functionality. label May 13, 2020
@Eugleo
Copy link
Author

Eugleo commented May 13, 2020

Great to hear it’s going to be included! Is it impossible to do even with some of the internal types? It’d be nice if I could use some solution before 0.5.2, even if it’s not so nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Issue suggests new or improved functionality.
Projects
None yet
Development

No branches or pull requests

2 participants