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 store phone numbers in Postgres? #1654

Closed
spease opened this Issue Apr 22, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@spease

spease commented Apr 22, 2018

This could also be generalized to "How to make a custom type work with diesel?"

Basically, I'd like to be able to load and store phone numbers that I'm storing with the phonenumber crate into a postgres database.

It looks like there's a postges extension for this:
https://github.com/blm768/pg-libphonenumber

But I'd just be happy with being able to do it with a text type for now.

I tried implementing FromSql and ToSql for a wrapper type as seen in this example:
https://github.com/diesel-rs/diesel/blob/master/diesel_tests/tests/custom_types.rs#L42

But this approach gets stuck on "only traits in the current crate can be implemented for arbitrary types".

Thanks.

@weiznich weiznich added the question label Apr 22, 2018

@weiznich

This comment has been minimized.

Contributor

weiznich commented Apr 22, 2018

In general it is totally possible to implement custom types outside of diesel. The test case you linked is basically the blue print for implementing such an type.

It is really hard to answer this question without any code to reproduce this. Please add the your current code and the current (exact) error to the issue.

I will close this issue because it does not contain anything that actionable for us to fix in diesel.
Feel free to update the issue with more informations. We will continue to answer this questions here. Or ask in our gitter channel.

@weiznich weiznich closed this Apr 22, 2018

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