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 upQuery dsl generated by select leak private types to public interface #1037
Comments
This comment has been minimized.
|
Yeah, seems like this lint should trigger, but I don't know the specifics. I think the original idea was to either use |
This comment has been minimized.
|
As written above, I know about the alternatives. It simply seems to be inconsistent to have private types in the public interface. |
This comment has been minimized.
|
Yes, sorry, that was a bit short. I only wanted to add some links to people finding this issue in the future had some more context. :) I don't think we can easily fix this right now, as the types are part of the API we don't want to stabilize without carefully thinking about and discussing it. But—I also did only think about this for a minute right now. What would you do? And, do you think we should document BoxedDsl somewhere prominently as a workaround? |
This comment has been minimized.
|
You aren't meant to ever reference these types correctly. You should use the types in http://docs.diesel.rs/diesel/helper_types/index.html |
sgrif
closed this
Jul 24, 2017
killercup
referenced this issue
Jul 24, 2017
Open
Document Diesel usage guidelines and edge cases #1038
This comment has been minimized.
|
How does one use those helper types when the query source is no raw table, but a join? Something like this? Select<Filter<Join<self::groups::table,
self::user_is_member_of_group::table,
joins::Inner>,
Eq<self::user_is_member_of_group::dsl::user_id,
Bound<Integer, i32>>>,
Nullable<self::groups::dsl::id>>for the following query groups.inner_join(user_is_member_of_group)
.filter(group_user_id.eq(self.id))
.select(id.nullable())Table dsl: table! {
groups {
id -> Integer,
group_name -> Text,
}
}
table! {
user_is_member_of_group (user_id, group_id) {
user_id -> Integer,
group_id -> Integer,
}
}
|
This comment has been minimized.
|
We should probably add helper types for |
weiznich commentedJul 24, 2017
Setup
Versions
Feature Flags
Problem Description
What are you trying to accomplish?
Return a common select query part from a function (I know of boxed queries)
What is the expected output?
The code compiles (even if the the returning type is somewhat complex)
What is the actual output?
It is impossible to import all needed types, because some of them are inside of a private module of diesel. Therefore it is not possible to write down those type.
(In theory there should be a lint(private_in_public) for this in rustc, but it seems like the lint failed to catch this types)
Steps to reproduce
Cause
This is basically caused because
query_builder::select_clauseand similar modules are private. Those types are used inquery_builder::select_statement::SelectStatementfor example as default types for the generic parameters.SelectStatementis exported as public type inquery_builderMaybe this should also be reported as bug of the private_in_public lint in rustc?
Checklist