Skip to content

Implementing ToSql #463

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

Closed
jplatte opened this issue Jul 17, 2019 · 4 comments
Closed

Implementing ToSql #463

jplatte opened this issue Jul 17, 2019 · 4 comments

Comments

@jplatte
Copy link

jplatte commented Jul 17, 2019

Currently, it is necessary to read the source to understand how to implement ToSql. Even then, one has to access #[doc(hidden)] code to keep with the style of the other implementations (is there a reason the to_sql_checked method can't have a default impl, or be part of an extension trait?).

Is it actually discouraged to implement ToSql for types local to ones crate, or is this just something that should be allowed, but nobody has bothered to make it a nice experience?

@sfackler
Copy link
Owner

What doc(hidden) code do you need access to? The trait is definitely intended to be implemented outside of the crate, but if there are things missing from its documentation we can add them.

To the best of my knowledge, it is not possible to avoid having to manually write a to_sql_checked implementation, but as the documentation notes, all of those should be generated by the to_sql_checked!() macro.

@jplatte
Copy link
Author

jplatte commented Jul 18, 2019

What doc(hidden) code do you need access to?

I was referring to fn __to_sql_checked that I found in the code, but actually the issue is that in the 0.16.0 release candidate, to_sql_checked! is no longer exported from the crate.

To the best of my knowledge, it is not possible to avoid having to manually write a to_sql_checked implementation

This is not at all obvious from the code. The to_sql_checked macro looks like it doesn't do anything a default implementation couldn't do. I guess I could just try it changing it and see what breaks though.

@sfackler
Copy link
Owner

I was referring to fn __to_sql_checked that I found in the code, but actually the issue is that in the 0.16.0 release candidate, to_sql_checked! is no longer exported from the crate.

Ah yeah, that should be exported down through tokio-postgres into postgres as well.

@jplatte
Copy link
Author

jplatte commented Jul 21, 2019

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants