File tree Expand file tree Collapse file tree 13 files changed +29
-6
lines changed
crates/crates_io_database/src/models Expand file tree Collapse file tree 13 files changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,10 @@ pub struct VersionOwnerAction {
54
54
55
55
impl VersionOwnerAction {
56
56
pub async fn all ( conn : & mut AsyncPgConnection ) -> QueryResult < Vec < Self > > {
57
- version_owner_actions:: table. load ( conn) . await
57
+ version_owner_actions:: table
58
+ . select ( Self :: as_select ( ) )
59
+ . load ( conn)
60
+ . await
58
61
}
59
62
60
63
pub fn by_version < ' a > (
@@ -100,6 +103,7 @@ impl NewVersionOwnerAction {
100
103
pub async fn insert ( & self , conn : & mut AsyncPgConnection ) -> QueryResult < VersionOwnerAction > {
101
104
diesel:: insert_into ( version_owner_actions:: table)
102
105
. values ( self )
106
+ . returning ( VersionOwnerAction :: as_select ( ) )
103
107
. get_result ( conn)
104
108
. await
105
109
}
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ impl Category {
55
55
async move {
56
56
let categories: Vec < Category > = categories:: table
57
57
. filter ( categories:: slug. eq_any ( slugs) )
58
+ . select ( Category :: as_select ( ) )
58
59
. load ( conn)
59
60
. await ?;
60
61
@@ -400,6 +401,7 @@ mod tests {
400
401
. unwrap ( ) ;
401
402
402
403
let cat: Category = Category :: by_slug ( "cat1::sub1" )
404
+ . select ( Category :: as_select ( ) )
403
405
. first ( & mut conn)
404
406
. await
405
407
. unwrap ( ) ;
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ impl CloudFrontInvalidationQueueItem {
39
39
cloudfront_invalidation_queue:: table
40
40
. order ( cloudfront_invalidation_queue:: created_at. asc ( ) )
41
41
. limit ( limit)
42
+ . select ( Self :: as_select ( ) )
42
43
. load ( conn)
43
44
. await
44
45
}
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ impl Keyword {
32
32
pub async fn find_by_keyword ( conn : & mut AsyncPgConnection , name : & str ) -> QueryResult < Keyword > {
33
33
keywords:: table
34
34
. filter ( keywords:: keyword. eq ( lower ( name) ) )
35
+ . select ( Keyword :: as_select ( ) )
35
36
. first ( conn)
36
37
. await
37
38
}
@@ -55,6 +56,7 @@ impl Keyword {
55
56
56
57
keywords:: table
57
58
. filter ( keywords:: keyword. eq_any ( & lowercase_names) )
59
+ . select ( Keyword :: as_select ( ) )
58
60
. load ( conn)
59
61
. await
60
62
}
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ impl NewTeam<'_> {
45
45
. on_conflict ( teams:: github_id)
46
46
. do_update ( )
47
47
. set ( self )
48
+ . returning ( Team :: as_returning ( ) )
48
49
. get_result ( conn)
49
50
. await
50
51
}
Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ mod tests {
73
73
// Retrieve the config
74
74
let retrieved_config = trustpub_configs_gitlab:: table
75
75
. filter ( trustpub_configs_gitlab:: id. eq ( inserted_config. id ) )
76
+ . select ( GitLabConfig :: as_select ( ) )
76
77
. first :: < GitLabConfig > ( & mut conn)
77
78
. await
78
79
. unwrap ( ) ;
Original file line number Diff line number Diff line change @@ -97,7 +97,10 @@ pub async fn find_category(
97
97
) -> AppResult < Json < GetResponse > > {
98
98
let mut conn = state. db_read ( ) . await ?;
99
99
100
- let cat: Category = Category :: by_slug ( & slug) . first ( & mut conn) . await ?;
100
+ let cat: Category = Category :: by_slug ( & slug)
101
+ . select ( Category :: as_select ( ) )
102
+ . first ( & mut conn)
103
+ . await ?;
101
104
let ( subcats, parents) = tokio:: try_join!(
102
105
cat. subcategories( & mut conn) ,
103
106
cat. parent_categories( & mut conn) . boxed( ) ,
Original file line number Diff line number Diff line change @@ -196,7 +196,8 @@ async fn prepare_list(
196
196
crate_owner_invitations:: invited_user_id,
197
197
) )
198
198
// We fetch one element over the page limit to then detect whether there is a next page.
199
- . limit ( pagination. per_page + 1 ) ;
199
+ . limit ( pagination. per_page + 1 )
200
+ . select ( CrateOwnerInvitation :: as_select ( ) ) ;
200
201
201
202
// Load and paginate the results.
202
203
let mut raw_invitations: Vec < CrateOwnerInvitation > = match pagination. page {
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ pub async fn list_keywords(
53
53
) -> AppResult < Json < ListResponse > > {
54
54
use crate :: schema:: keywords;
55
55
56
- let mut query = keywords:: table. into_boxed ( ) ;
56
+ let mut query = keywords:: table. select ( Keyword :: as_select ( ) ) . into_boxed ( ) ;
57
57
58
58
query = match & params. sort {
59
59
Some ( sort) if sort == "crates" => query. order ( keywords:: crates_cnt. desc ( ) ) ,
Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ pub async fn get_summary(state: AppState) -> AppResult<Json<SummaryResponse>> {
118
118
keywords:: table
119
119
. order( keywords:: crates_cnt. desc( ) )
120
120
. limit( 10 )
121
+ . select( Keyword :: as_select( ) )
121
122
. load( & mut conn)
122
123
. boxed( ) ,
123
124
) ?;
You can’t perform that action at this time.
0 commit comments