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

Rust enum to sql integer how to ? #503

Closed
sackery opened this Issue Nov 28, 2016 · 7 comments

Comments

Projects
None yet
6 participants
@sackery

sackery commented Nov 28, 2016

No description provided.

@weiznich

This comment has been minimized.

Contributor

weiznich commented Nov 28, 2016

There is #429 open, which add support for adding custom type mapping. This could be used to map an enum to an integer.
@sgrif stated in #483 he is not sure if he want to add support for this in diesel. I've extracted the corresponding code here so it could be used without landing this pull-request. (If needed I could also upload it to crates.io)

@killercup

This comment has been minimized.

Member

killercup commented Jan 5, 2017

FYI tracking issue for Postgres' custom enum types is #343

@quadrupleslap

This comment has been minimized.

quadrupleslap commented Feb 4, 2017

Pointing out the obvious, it's easy to cast it into an integer with as and match it back if you wanted to, but that removes the guarantee that values always represent the variants of the enum.

@dbrgn

This comment has been minimized.

Contributor

dbrgn commented Apr 3, 2017

I'd also like to request some documentation on this issue. I managed to implement FromSqlRow for a String based enum with the help from #429, but I can't get AsExpression working.

@dbrgn

This comment has been minimized.

Contributor

dbrgn commented Apr 3, 2017

@sgrif

This comment has been minimized.

Member

sgrif commented Dec 16, 2017

Closing for the same reasons as #343 (comment)

@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