@@ -22,28 +22,28 @@ use crate::sql_types::{BigInt, Bool, NotNull, Nullable};
2222
2323#[ allow( missing_debug_implementations) ]
2424pub struct BoxedSelectStatement < ' a , ST , QS , DB > {
25- select : Box < dyn QueryFragment < DB > + ' a > ,
25+ select : Box < dyn QueryFragment < DB > + Send + ' a > ,
2626 from : QS ,
27- distinct : Box < dyn QueryFragment < DB > + ' a > ,
27+ distinct : Box < dyn QueryFragment < DB > + Send + ' a > ,
2828 where_clause : BoxedWhereClause < ' a , DB > ,
29- order : Option < Box < dyn QueryFragment < DB > + ' a > > ,
30- limit : Box < dyn QueryFragment < DB > + ' a > ,
31- offset : Box < dyn QueryFragment < DB > + ' a > ,
32- group_by : Box < dyn QueryFragment < DB > + ' a > ,
29+ order : Option < Box < dyn QueryFragment < DB > + Send + ' a > > ,
30+ limit : Box < dyn QueryFragment < DB > + Send + ' a > ,
31+ offset : Box < dyn QueryFragment < DB > + Send + ' a > ,
32+ group_by : Box < dyn QueryFragment < DB > + Send + ' a > ,
3333 _marker : PhantomData < ST > ,
3434}
3535
3636impl < ' a , ST , QS , DB > BoxedSelectStatement < ' a , ST , QS , DB > {
3737 #[ allow( clippy:: too_many_arguments) ]
3838 pub fn new (
39- select : Box < dyn QueryFragment < DB > + ' a > ,
39+ select : Box < dyn QueryFragment < DB > + Send + ' a > ,
4040 from : QS ,
41- distinct : Box < dyn QueryFragment < DB > + ' a > ,
41+ distinct : Box < dyn QueryFragment < DB > + Send + ' a > ,
4242 where_clause : BoxedWhereClause < ' a , DB > ,
43- order : Option < Box < dyn QueryFragment < DB > + ' a > > ,
44- limit : Box < dyn QueryFragment < DB > + ' a > ,
45- offset : Box < dyn QueryFragment < DB > + ' a > ,
46- group_by : Box < dyn QueryFragment < DB > + ' a > ,
43+ order : Option < Box < dyn QueryFragment < DB > + Send + ' a > > ,
44+ limit : Box < dyn QueryFragment < DB > + Send + ' a > ,
45+ offset : Box < dyn QueryFragment < DB > + Send + ' a > ,
46+ group_by : Box < dyn QueryFragment < DB > + Send + ' a > ,
4747 ) -> Self {
4848 BoxedSelectStatement {
4949 select : select,
@@ -164,7 +164,7 @@ where
164164impl < ' a , ST , QS , DB , Selection > SelectDsl < Selection > for BoxedSelectStatement < ' a , ST , QS , DB >
165165where
166166 DB : Backend ,
167- Selection : SelectableExpression < QS > + QueryFragment < DB > + ' a ,
167+ Selection : SelectableExpression < QS > + QueryFragment < DB > + Send + ' a ,
168168{
169169 type Output = BoxedSelectStatement < ' a , Selection :: SqlType , QS , DB > ;
170170
@@ -237,7 +237,7 @@ where
237237impl < ' a , ST , QS , DB , Order > OrderDsl < Order > for BoxedSelectStatement < ' a , ST , QS , DB >
238238where
239239 DB : Backend ,
240- Order : QueryFragment < DB > + AppearsOnTable < QS > + ' a ,
240+ Order : QueryFragment < DB > + AppearsOnTable < QS > + Send + ' a ,
241241{
242242 type Output = Self ;
243243
@@ -250,7 +250,7 @@ where
250250impl < ' a , ST , QS , DB , Order > ThenOrderDsl < Order > for BoxedSelectStatement < ' a , ST , QS , DB >
251251where
252252 DB : Backend + ' a ,
253- Order : QueryFragment < DB > + AppearsOnTable < QS > + ' a ,
253+ Order : QueryFragment < DB > + AppearsOnTable < QS > + Send + ' a ,
254254{
255255 type Output = Self ;
256256
@@ -266,7 +266,7 @@ where
266266impl < ' a , ST , QS , DB , Expr > GroupByDsl < Expr > for BoxedSelectStatement < ' a , ST , QS , DB >
267267where
268268 DB : Backend ,
269- Expr : QueryFragment < DB > + AppearsOnTable < QS > + ' a ,
269+ Expr : QueryFragment < DB > + AppearsOnTable < QS > + Send + ' a ,
270270 Self : Query ,
271271{
272272 type Output = Self ;
@@ -340,3 +340,38 @@ where
340340 }
341341 }
342342}
343+
344+ #[ cfg( test) ]
345+ mod tests {
346+ use crate :: backend:: Backend ;
347+ use crate :: prelude:: * ;
348+
349+ table ! {
350+ users {
351+ id -> Integer ,
352+ }
353+ }
354+
355+ fn assert_send < T > ( _: T )
356+ where
357+ T : Send ,
358+ {
359+ }
360+
361+ fn assert_boxed_query_send < B : Backend > ( ) {
362+ assert_send ( users:: table. into_boxed :: < B > ( ) ) ;
363+ assert_send ( users:: table. filter ( users:: id. eq ( 10 ) ) . into_boxed :: < B > ( ) ) ;
364+ }
365+
366+ #[ test]
367+ fn boxed_is_send ( ) {
368+ #[ cfg( feature = "postgres" ) ]
369+ assert_boxed_query_send :: < crate :: pg:: Pg > ( ) ;
370+
371+ #[ cfg( feature = "sqlite" ) ]
372+ assert_boxed_query_send :: < crate :: sqlite:: Sqlite > ( ) ;
373+
374+ #[ cfg( feature = "mysql" ) ]
375+ assert_boxed_query_send :: < crate :: mysql:: Mysql > ( ) ;
376+ }
377+ }
0 commit comments