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

Support user-defined `FromSql` and `ToSql` implementations #348

Closed
kardeiz opened this Issue Jun 1, 2016 · 3 comments

Comments

Projects
None yet
4 participants
@kardeiz
Contributor

kardeiz commented Jun 1, 2016

It would be nice if it were easier to write one's own FromSql and ToSql implementations.

In my understanding (I could be wrong), this is actually possible—all the required traits, etc. are public—but all of the traits implemented by the expression_impls and queryable_impls macros have to be written by hand, because these macros are not publicly exposed.

Would it be possible to export these macros as well, or provide some other functionality to facilitate these conversions?

@jimmycuadra

This comment has been minimized.

Contributor

jimmycuadra commented Aug 17, 2016

I'm also wondering this. In my case, I want to use a custom type in a table struct that Diesel should treat as a String for all intents and purposes. It's not clear to me how to achieve this. I started out by trying to just implement ToSql for my type, but it seems like there is a rabbit hole of traits that need to be satisfied, cause I get errors like "diesel::Expression is not satisfied" and "diesel::Expression:NonAggregate is not satisfied."

@leoschwarz

This comment has been minimized.

leoschwarz commented May 8, 2017

I have the same problem right now, apparently the situation has still not improved by much or I'm not able to find the relevant modules.

(Also I think this and #162 are essentially duplicates.)

@sgrif

This comment has been minimized.

Member

sgrif commented Dec 16, 2017

Closing as a duplicate of #162.

@sgrif sgrif closed this Dec 16, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment