Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upImplementing `diesel::Expression`, etc., for custom types outside diesel? #562
Comments
emk
changed the title from
Implemetnting `diesel::Expression`, etc., for custom types outside diesel?
to
Implementing `diesel::Expression`, etc., for custom types outside diesel?
Dec 31, 2016
This comment has been minimized.
Not at the moment. We should probably make those macros public (with a Anyway it needs further exploration and discussion. I'm fine with making those macros public for the time being if you'd like to open a PR. |
This comment has been minimized.
|
I am preparing a small PR to make the macros public, as I would like to use them as well. Would it make sense to also make Edit: There's also |
aperezdc
referenced this issue
Jan 12, 2017
Merged
Make macros public to allow easily implementing traits outside of diesel #574
This comment has been minimized.
|
Thanks for this effort. It should make it easier to deal with #343. AIUI, registering a new type Edit: Sorry, I should have read the issue more closely. It looks like you are not adding a new database type, but registering a Rust type for use with Diesel. Please disregard the above if it does not actually apply to your situation. |
This comment has been minimized.
|
@DTSu No, |
This comment has been minimized.
|
Did the details of how to do this change in diesel 0.10? I'm now getting these errors, using diesel and diesel_codegen 0.10.0 (with the postgres feature):
The struct in question is: #[derive(AsChangeset, Debug, Clone, Identifiable, Insertable, Queryable)]
#[table_name = "profiles"]
pub struct Profile {
pub id: ruma_identifiers::UserId,
pub avatar_url: Option<String>,
pub displayname: Option<String>,
}The previously working implementations for |
This comment has been minimized.
|
Moving my question to its own issue: #640 |
This comment has been minimized.
|
Closing as a duplicate of #162. See #343 (comment) for some thoughts on this. |
sgrif
closed this
Dec 16, 2017
This comment has been minimized.
|
Also I should expand on this a little bit since this issue is slightly different. Specifically for the case of "implementing support for a Rust type that is not crate local, for a SQL type which is crate local" (an example of this is implementing support for |
emk commentedDec 31, 2016
•
edited
As a followup to #561, I'd like to try defining a custom
ToSqlandFromSqlimplementation for a type in a crate besidesdiesel. I'm going to try this with https://github.com/faradayio/bigml-rs, which a client for the commercial BigML machine learning service.This crate contains a type
Id, which represents a string of the formsource/1234orexecution/5678. Because these strings refer to different types of resources, theIdtype takes parameters:Id<Source>orId<Execution>. So far, no problems.I can declare
ToSqlandFromSqlinstances as follows:But if I try to use these impls, I run into problems. This code:
...gives me the errors:
It looks like the missing pieces are basically:
But the macros
queryable_impls!andexpression_impls!are private, and relatively large and complex. Is there a story for implementing these traits correctly from outsidedieselitself?