1use super::BoxedSelectStatement;
2use crate::associations::HasTable;
3use crate::backend::Backend;
4use crate::dsl::AsExprOf;
5use crate::expression::nullable::Nullable;
6use crate::expression::*;
7use crate::insertable::Insertable;
8use crate::query_builder::NoFromClause;
9use crate::query_builder::combination_clause::*;
10use crate::query_builder::distinct_clause::*;
11use crate::query_builder::from_clause::AsQuerySource;
12use crate::query_builder::from_clause::FromClause;
13use crate::query_builder::group_by_clause::*;
14use crate::query_builder::insert_statement::InsertFromSelect;
15use crate::query_builder::limit_clause::*;
16use crate::query_builder::limit_offset_clause::{BoxedLimitOffsetClause, LimitOffsetClause};
17use crate::query_builder::locking_clause::*;
18use crate::query_builder::offset_clause::*;
19use crate::query_builder::order_clause::*;
20use crate::query_builder::select_clause::*;
21use crate::query_builder::update_statement::target::*;
22use crate::query_builder::where_clause::*;
23use crate::query_builder::{
24 AsQuery, IntoBoxedClause, Query, QueryFragment, SelectQuery, SelectStatement,
25};
26use crate::query_dsl::group_by_dsl::ValidDistinctForGroupBy;
27use crate::query_dsl::methods::*;
28use crate::query_dsl::order_dsl::ValidOrderingForDistinct;
29use crate::query_dsl::*;
30use crate::query_source::QuerySource;
31use crate::query_source::joins::{Join, JoinOn, JoinTo};
32use crate::sql_types::{BigInt, BoolOrNullableBool};
33use alloc::boxed::Box;
34
35impl<F, D, W, O, LOf, G, H, LC, Rhs, Kind, On> InternalJoinDsl<Rhs, Kind, On>
36 for SelectStatement<FromClause<F>, DefaultSelectClause<FromClause<F>>, D, W, O, LOf, G, H, LC>
37where
38 F: QuerySource,
39 Rhs: QuerySource,
40 JoinOn<Join<F, Rhs, Kind>, On>: QuerySource,
41 SelectStatement<
42 FromClause<JoinOn<Join<F, Rhs, Kind>, On>>,
43 DefaultSelectClause<FromClause<JoinOn<Join<F, Rhs, Kind>, On>>>,
44 D,
45 W,
46 O,
47 LOf,
48 G,
49 H,
50 LC,
51 >: AsQuery,
52{
53 type Output = SelectStatement<
54 FromClause<JoinOn<Join<F, Rhs, Kind>, On>>,
55 DefaultSelectClause<FromClause<JoinOn<Join<F, Rhs, Kind>, On>>>,
56 D,
57 W,
58 O,
59 LOf,
60 G,
61 H,
62 LC,
63 >;
64
65 fn join(self, rhs: Rhs, kind: Kind, on: On) -> Self::Output {
66 let from = FromClause::new(Join::new(self.from.source, rhs, kind).on(on));
67 SelectStatement::new(
68 DefaultSelectClause::new(&from),
69 from,
70 self.distinct,
71 self.where_clause,
72 self.order,
73 self.limit_offset,
74 self.group_by,
75 self.having,
76 self.locking,
77 )
78 }
79}
80
81impl<F, S, D, W, O, LOf, G, H, LC, Rhs, Kind, On> InternalJoinDsl<Rhs, Kind, On>
82 for SelectStatement<FromClause<F>, SelectClause<S>, D, W, O, LOf, G, H, LC>
83where
84 F: QuerySource,
85 Rhs: QuerySource,
86 JoinOn<Join<F, Rhs, Kind>, On>: QuerySource,
87 SelectStatement<
88 FromClause<JoinOn<Join<F, Rhs, Kind>, On>>,
89 SelectClause<S>,
90 D,
91 W,
92 O,
93 LOf,
94 G,
95 H,
96 LC,
97 >: AsQuery,
98{
99 type Output = SelectStatement<
100 FromClause<JoinOn<Join<F, Rhs, Kind>, On>>,
101 SelectClause<S>,
102 D,
103 W,
104 O,
105 LOf,
106 G,
107 H,
108 LC,
109 >;
110
111 fn join(self, rhs: Rhs, kind: Kind, on: On) -> Self::Output {
112 SelectStatement::new(
113 self.select,
114 FromClause::new(Join::new(self.from.source, rhs, kind).on(on)),
115 self.distinct,
116 self.where_clause,
117 self.order,
118 self.limit_offset,
119 self.group_by,
120 self.having,
121 self.locking,
122 )
123 }
124}
125
126impl<F, S, D, W, O, LOf, G, H, LC, Selection> SelectDsl<Selection>
127 for SelectStatement<FromClause<F>, S, D, W, O, LOf, G, H, LC>
128where
129 G: ValidGroupByClause,
130 F: QuerySource,
131 Selection: SelectableExpression<F> + ValidGrouping<G::Expressions>,
132 SelectStatement<FromClause<F>, SelectClause<Selection>, D, W, O, LOf, G, H, LC>: SelectQuery,
133 D: ValidDistinctForGroupBy<Selection, G::Expressions>,
134{
135 type Output = SelectStatement<FromClause<F>, SelectClause<Selection>, D, W, O, LOf, G, H, LC>;
136
137 fn select(self, selection: Selection) -> Self::Output {
138 SelectStatement::new(
139 SelectClause(selection),
140 self.from,
141 self.distinct,
142 self.where_clause,
143 self.order,
144 self.limit_offset,
145 self.group_by,
146 self.having,
147 self.locking,
148 )
149 }
150}
151
152impl<S, D, W, O, LOf, G, H, LC, Selection> SelectDsl<Selection>
153 for SelectStatement<NoFromClause, S, D, W, O, LOf, G, H, LC>
154where
155 G: ValidGroupByClause,
156 Selection: SelectableExpression<NoFromClause> + ValidGrouping<G::Expressions>,
157 SelectStatement<NoFromClause, SelectClause<Selection>, D, W, O, LOf, G, H, LC>: SelectQuery,
158 D: ValidDistinctForGroupBy<Selection, G::Expressions>,
159{
160 type Output = SelectStatement<NoFromClause, SelectClause<Selection>, D, W, O, LOf, G, H, LC>;
161
162 fn select(self, selection: Selection) -> Self::Output {
163 SelectStatement::new(
164 SelectClause(selection),
165 self.from,
166 self.distinct,
167 self.where_clause,
168 self.order,
169 self.limit_offset,
170 self.group_by,
171 self.having,
172 self.locking,
173 )
174 }
175}
176
177impl<ST, F, S, D, W, O, LOf, G, H> DistinctDsl for SelectStatement<F, S, D, W, O, LOf, G, H>
178where
179 Self: SelectQuery<SqlType = ST>,
180 SelectStatement<F, S, DistinctClause, W, O, LOf, G, H>: SelectQuery<SqlType = ST>,
181{
182 type Output = SelectStatement<F, S, DistinctClause, W, O, LOf, G, H>;
183
184 fn distinct(self) -> Self::Output {
185 SelectStatement::new(
186 self.select,
187 self.from,
188 DistinctClause,
189 self.where_clause,
190 self.order,
191 self.limit_offset,
192 self.group_by,
193 self.having,
194 self.locking,
195 )
196 }
197}
198
199impl<F, S, D, W, O, LOf, G, H, LC, Predicate> FilterDsl<Predicate>
200 for SelectStatement<F, S, D, W, O, LOf, G, H, LC>
201where
202 Predicate: Expression + NonAggregate,
203 Predicate::SqlType: BoolOrNullableBool,
204 W: WhereAnd<Predicate>,
205{
206 type Output = SelectStatement<F, S, D, W::Output, O, LOf, G, H, LC>;
207
208 fn filter(self, predicate: Predicate) -> Self::Output {
209 SelectStatement::new(
210 self.select,
211 self.from,
212 self.distinct,
213 self.where_clause.and(predicate),
214 self.order,
215 self.limit_offset,
216 self.group_by,
217 self.having,
218 self.locking,
219 )
220 }
221}
222
223impl<F, S, D, W, O, LOf, G, H, LC, Predicate> OrFilterDsl<Predicate>
224 for SelectStatement<F, S, D, W, O, LOf, G, H, LC>
225where
226 Predicate: Expression + NonAggregate,
227 Predicate::SqlType: BoolOrNullableBool,
228 W: WhereOr<Predicate>,
229{
230 type Output = SelectStatement<F, S, D, W::Output, O, LOf, G, H, LC>;
231
232 fn or_filter(self, predicate: Predicate) -> Self::Output {
233 SelectStatement::new(
234 self.select,
235 self.from,
236 self.distinct,
237 self.where_clause.or(predicate),
238 self.order,
239 self.limit_offset,
240 self.group_by,
241 self.having,
242 self.locking,
243 )
244 }
245}
246
247use crate::dsl::Filter;
248use crate::expression_methods::EqAll;
249use crate::query_builder::having_clause::{HavingClause, NoHavingClause};
250use crate::query_source::Table;
251
252impl<F, S, D, W, O, LOf, G, H, LC, PK> FindDsl<PK>
253 for SelectStatement<FromClause<F>, S, D, W, O, LOf, G, H, LC>
254where
255 F: Table,
256 F::PrimaryKey: EqAll<PK>,
257 Self: FilterDsl<<F::PrimaryKey as EqAll<PK>>::Output>,
258{
259 type Output = Filter<Self, <F::PrimaryKey as EqAll<PK>>::Output>;
260
261 fn find(self, id: PK) -> Self::Output {
262 let primary_key = self.from.source.primary_key();
263 FilterDsl::filter(self, primary_key.eq_all(id))
264 }
265}
266
267impl<ST, F, S, D, W, O, LOf, G, H, LC, Expr> OrderDsl<Expr>
269 for SelectStatement<FromClause<F>, S, D, W, O, LOf, G, H, LC>
270where
271 F: QuerySource,
272 Expr: AppearsOnTable<F>,
273 Self: SelectQuery<SqlType = ST>,
274 SelectStatement<FromClause<F>, S, D, W, OrderClause<Expr>, LOf, G, H, LC>:
275 SelectQuery<SqlType = ST>,
276 OrderClause<Expr>: ValidOrderingForDistinct<D>,
277{
278 type Output = SelectStatement<FromClause<F>, S, D, W, OrderClause<Expr>, LOf, G, H, LC>;
279
280 fn order(self, expr: Expr) -> Self::Output {
281 let order = OrderClause(expr);
282 SelectStatement::new(
283 self.select,
284 self.from,
285 self.distinct,
286 self.where_clause,
287 order,
288 self.limit_offset,
289 self.group_by,
290 self.having,
291 self.locking,
292 )
293 }
294}
295
296impl<F, S, D, W, O, LOf, G, H, LC, Expr> ThenOrderDsl<Expr>
297 for SelectStatement<FromClause<F>, S, D, W, OrderClause<O>, LOf, G, H, LC>
298where
299 F: QuerySource,
300 Expr: AppearsOnTable<F>,
301{
302 type Output = SelectStatement<FromClause<F>, S, D, W, OrderClause<(O, Expr)>, LOf, G, H, LC>;
303
304 fn then_order_by(self, expr: Expr) -> Self::Output {
305 SelectStatement::new(
306 self.select,
307 self.from,
308 self.distinct,
309 self.where_clause,
310 OrderClause((self.order.0, expr)),
311 self.limit_offset,
312 self.group_by,
313 self.having,
314 self.locking,
315 )
316 }
317}
318
319impl<F, S, D, W, LOf, G, LC, Expr> ThenOrderDsl<Expr>
320 for SelectStatement<F, S, D, W, NoOrderClause, LOf, G, LC>
321where
322 Expr: Expression,
323 Self: OrderDsl<Expr>,
324{
325 type Output = crate::dsl::Order<Self, Expr>;
326
327 fn then_order_by(self, expr: Expr) -> Self::Output {
328 self.order_by(expr)
329 }
330}
331
332#[doc(hidden)]
333type Limit = AsExprOf<i64, BigInt>;
334
335impl<ST, F, S, D, W, O, L, Of, G, H, LC> LimitDsl
336 for SelectStatement<F, S, D, W, O, LimitOffsetClause<L, Of>, G, H, LC>
337where
338 Self: SelectQuery<SqlType = ST>,
339 SelectStatement<F, S, D, W, O, LimitOffsetClause<LimitClause<Limit>, Of>, G, H, LC>:
340 SelectQuery<SqlType = ST>,
341{
342 type Output =
343 SelectStatement<F, S, D, W, O, LimitOffsetClause<LimitClause<Limit>, Of>, G, H, LC>;
344
345 fn limit(self, limit: i64) -> Self::Output {
346 let limit_clause = LimitClause(limit.into_sql::<BigInt>());
347 SelectStatement::new(
348 self.select,
349 self.from,
350 self.distinct,
351 self.where_clause,
352 self.order,
353 LimitOffsetClause {
354 limit_clause,
355 offset_clause: self.limit_offset.offset_clause,
356 },
357 self.group_by,
358 self.having,
359 self.locking,
360 )
361 }
362}
363
364#[doc(hidden)]
365type Offset = Limit;
366
367impl<ST, F, S, D, W, O, L, Of, G, H, LC> OffsetDsl
368 for SelectStatement<F, S, D, W, O, LimitOffsetClause<L, Of>, G, H, LC>
369where
370 Self: SelectQuery<SqlType = ST>,
371 SelectStatement<F, S, D, W, O, LimitOffsetClause<L, OffsetClause<Offset>>, G, H, LC>:
372 SelectQuery<SqlType = ST>,
373{
374 type Output =
375 SelectStatement<F, S, D, W, O, LimitOffsetClause<L, OffsetClause<Offset>>, G, H, LC>;
376
377 fn offset(self, offset: i64) -> Self::Output {
378 let offset_clause = OffsetClause(offset.into_sql::<BigInt>());
379 SelectStatement::new(
380 self.select,
381 self.from,
382 self.distinct,
383 self.where_clause,
384 self.order,
385 LimitOffsetClause {
386 limit_clause: self.limit_offset.limit_clause,
387 offset_clause,
388 },
389 self.group_by,
390 self.having,
391 self.locking,
392 )
393 }
394}
395
396impl<F, S, D, W, O, LOf, G, H, Expr> GroupByDsl<Expr> for SelectStatement<F, S, D, W, O, LOf, G, H>
397where
398 SelectStatement<F, S, D, W, O, LOf, GroupByClause<Expr>, H>: SelectQuery,
399 Expr: Expression + AppearsOnTable<F>,
400{
401 type Output = SelectStatement<F, S, D, W, O, LOf, GroupByClause<Expr>, H>;
402
403 fn group_by(self, expr: Expr) -> Self::Output {
404 let group_by = GroupByClause(expr);
405 SelectStatement::new(
406 self.select,
407 self.from,
408 self.distinct,
409 self.where_clause,
410 self.order,
411 self.limit_offset,
412 group_by,
413 self.having,
414 self.locking,
415 )
416 }
417}
418
419impl<F, S, W, O, LOf, Lock> LockingDsl<Lock>
420 for SelectStatement<F, S, NoDistinctClause, W, O, LOf>
421{
422 type Output = SelectStatement<
423 F,
424 S,
425 NoDistinctClause,
426 W,
427 O,
428 LOf,
429 NoGroupByClause,
430 NoHavingClause,
431 LockingClause<Lock, NoModifier>,
432 >;
433
434 fn with_lock(self, lock: Lock) -> Self::Output {
435 SelectStatement::new(
436 self.select,
437 self.from,
438 self.distinct,
439 self.where_clause,
440 self.order,
441 self.limit_offset,
442 self.group_by,
443 self.having,
444 LockingClause::new(lock, NoModifier),
445 )
446 }
447}
448
449impl<F, S, D, W, O, LOf, G, H, LC, LM, Modifier> ModifyLockDsl<Modifier>
450 for SelectStatement<F, S, D, W, O, LOf, G, H, LockingClause<LC, LM>>
451{
452 type Output = SelectStatement<F, S, D, W, O, LOf, G, H, LockingClause<LC, Modifier>>;
453
454 fn modify_lock(self, modifier: Modifier) -> Self::Output {
455 SelectStatement::new(
456 self.select,
457 self.from,
458 self.distinct,
459 self.where_clause,
460 self.order,
461 self.limit_offset,
462 self.group_by,
463 self.having,
464 LockingClause::new(self.locking.lock_mode, modifier),
465 )
466 }
467}
468
469impl<'a, F, S, D, W, O, LOf, G, H, DB> BoxedDsl<'a, DB>
470 for SelectStatement<FromClause<F>, S, D, W, O, LOf, G, H>
471where
472 Self: AsQuery,
473 DB: Backend,
474 F: QuerySource,
475 S: SelectClauseExpression<FromClause<F>> + QueryFragment<DB> + Send + 'a,
476 S::Selection: ValidGrouping<G::Expressions>,
477 D: QueryFragment<DB> + Send + 'a,
478 W: Into<BoxedWhereClause<'a, DB>>,
479 O: Into<Option<Box<dyn QueryFragment<DB> + Send + 'a>>>,
480 LOf: IntoBoxedClause<'a, DB, BoxedClause = BoxedLimitOffsetClause<'a, DB>>,
481 G: ValidGroupByClause + QueryFragment<DB> + Send + 'a,
482 H: QueryFragment<DB> + Send + 'a,
483{
484 type Output =
485 BoxedSelectStatement<'a, S::SelectClauseSqlType, FromClause<F>, DB, G::Expressions>;
486
487 fn internal_into_boxed(self) -> Self::Output {
488 BoxedSelectStatement::new(
489 self.select,
490 self.from,
491 Box::new(self.distinct),
492 self.where_clause.into(),
493 self.order.into(),
494 self.limit_offset.into_boxed(),
495 self.group_by,
496 Box::new(self.having),
497 )
498 }
499}
500
501impl<'a, S, D, W, O, LOf, G, H, DB> BoxedDsl<'a, DB>
502 for SelectStatement<NoFromClause, S, D, W, O, LOf, G, H>
503where
504 Self: AsQuery,
505 DB: Backend,
506 S: SelectClauseExpression<NoFromClause> + QueryFragment<DB> + Send + 'a,
507 S::Selection: ValidGrouping<G::Expressions>,
508 D: QueryFragment<DB> + Send + 'a,
509 W: Into<BoxedWhereClause<'a, DB>>,
510 O: Into<Option<Box<dyn QueryFragment<DB> + Send + 'a>>>,
511 LOf: IntoBoxedClause<'a, DB, BoxedClause = BoxedLimitOffsetClause<'a, DB>>,
512 G: ValidGroupByClause + QueryFragment<DB> + Send + 'a,
513 H: QueryFragment<DB> + Send + 'a,
514{
515 type Output =
516 BoxedSelectStatement<'a, S::SelectClauseSqlType, NoFromClause, DB, G::Expressions>;
517
518 fn internal_into_boxed(self) -> Self::Output {
519 BoxedSelectStatement::new_no_from_clause(
520 self.select,
521 self.from,
522 Box::new(self.distinct),
523 self.where_clause.into(),
524 self.order.into(),
525 self.limit_offset.into_boxed(),
526 self.group_by,
527 Box::new(self.having),
528 )
529 }
530}
531
532impl<F, S, D, W, O, LOf, G, H, LC> HasTable
533 for SelectStatement<FromClause<F>, S, D, W, O, LOf, G, H, LC>
534where
535 F: HasTable + QuerySource,
536{
537 type Table = F::Table;
538
539 fn table() -> Self::Table {
540 F::table()
541 }
542}
543
544impl<F, W> IntoUpdateTarget
545 for SelectStatement<FromClause<F>, DefaultSelectClause<FromClause<F>>, NoDistinctClause, W>
546where
547 F: QuerySource,
548 Self: HasTable,
549 W: ValidWhereClause<F>,
550{
551 type WhereClause = W;
552
553 fn into_update_target(self) -> UpdateTarget<Self::Table, Self::WhereClause> {
554 UpdateTarget {
555 table: Self::table(),
556 where_clause: self.where_clause,
557 }
558 }
559}
560
561impl<F, S, D, W, O, LOf, G, H, LC, Rhs> JoinTo<Rhs>
565 for SelectStatement<FromClause<F>, S, D, W, O, LOf, G, H, LC>
566where
567 F: JoinTo<Rhs> + QuerySource,
568{
569 type FromClause = <F as JoinTo<Rhs>>::FromClause;
570 type OnClause = F::OnClause;
571
572 fn join_target(rhs: Rhs) -> (Self::FromClause, Self::OnClause) {
573 F::join_target(rhs)
574 }
575}
576
577impl<F, S, D, W, O, LOf, G, H, LC> QueryDsl for SelectStatement<F, S, D, W, O, LOf, G, H, LC> {}
578
579impl<F, S, D, W, O, LOf, G, H, LC, Conn> RunQueryDsl<Conn>
580 for SelectStatement<F, S, D, W, O, LOf, G, H, LC>
581{
582}
583
584impl<F, S, D, W, O, LOf, G, H, LC, Tab> Insertable<Tab>
585 for SelectStatement<F, S, D, W, O, LOf, G, H, LC>
586where
587 Tab: Table,
588 Self: Query,
589 <Tab::AllColumns as ValidGrouping<()>>::IsAggregate:
590 MixedAggregates<is_aggregate::No, Output = is_aggregate::No>,
591{
592 type Values = InsertFromSelect<Self, Tab::AllColumns>;
593
594 fn values(self) -> Self::Values {
595 InsertFromSelect::new(self)
596 }
597}
598
599impl<F, S, D, W, O, LOf, G, H, LC, Tab> Insertable<Tab>
600 for &SelectStatement<F, S, D, W, O, LOf, G, H, LC>
601where
602 Tab: Table,
603 Self: Query,
604 <Tab::AllColumns as ValidGrouping<()>>::IsAggregate:
605 MixedAggregates<is_aggregate::No, Output = is_aggregate::No>,
606{
607 type Values = InsertFromSelect<Self, Tab::AllColumns>;
608
609 fn values(self) -> Self::Values {
610 InsertFromSelect::new(self)
611 }
612}
613
614impl<F, S, D, W, O, LOf, G, H> SelectNullableDsl
615 for SelectStatement<F, SelectClause<S>, D, W, O, LOf, G, H>
616{
617 type Output = SelectStatement<F, SelectClause<Nullable<S>>, D, W, O, LOf, G, H>;
618
619 fn nullable(self) -> Self::Output {
620 SelectStatement::new(
621 SelectClause(Nullable::new(self.select.0)),
622 self.from,
623 self.distinct,
624 self.where_clause,
625 self.order,
626 self.limit_offset,
627 self.group_by,
628 self.having,
629 self.locking,
630 )
631 }
632}
633
634impl<F, D, W, O, LOf, G, H> SelectNullableDsl
635 for SelectStatement<F, DefaultSelectClause<F>, D, W, O, LOf, G, H>
636where
637 F: AsQuerySource,
638{
639 type Output = SelectStatement<
640 F,
641 SelectClause<Nullable<<F::QuerySource as QuerySource>::DefaultSelection>>,
642 D,
643 W,
644 O,
645 LOf,
646 G,
647 H,
648 >;
649
650 fn nullable(self) -> Self::Output {
651 SelectStatement::new(
652 SelectClause(Nullable::new(
653 self.from.as_query_source().default_selection(),
654 )),
655 self.from,
656 self.distinct,
657 self.where_clause,
658 self.order,
659 self.limit_offset,
660 self.group_by,
661 self.having,
662 self.locking,
663 )
664 }
665}
666
667impl<F, S, D, W, O, LOf, G, H, Predicate> HavingDsl<Predicate>
668 for SelectStatement<FromClause<F>, S, D, W, O, LOf, GroupByClause<G>, H>
669where
670 F: QuerySource,
671 Predicate: AppearsOnTable<F>,
672 Predicate: Expression,
673 Predicate::SqlType: BoolOrNullableBool,
674{
675 type Output =
676 SelectStatement<FromClause<F>, S, D, W, O, LOf, GroupByClause<G>, HavingClause<Predicate>>;
677
678 fn having(self, predicate: Predicate) -> Self::Output {
679 SelectStatement::new(
680 self.select,
681 self.from,
682 self.distinct,
683 self.where_clause,
684 self.order,
685 self.limit_offset,
686 self.group_by,
687 HavingClause(predicate),
688 self.locking,
689 )
690 }
691}
692
693impl<F, S, D, W, O, LOf, G, H, LC> CombineDsl for SelectStatement<F, S, D, W, O, LOf, G, H, LC>
694where
695 Self: Query,
696{
697 type Query = Self;
698
699 fn union<Rhs>(self, rhs: Rhs) -> crate::dsl::Union<Self, Rhs>
700 where
701 Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>,
702 {
703 CombinationClause::new(Union, Distinct, self, rhs.as_query())
704 }
705
706 fn union_all<Rhs>(self, rhs: Rhs) -> crate::dsl::UnionAll<Self, Rhs>
707 where
708 Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>,
709 {
710 CombinationClause::new(Union, All, self, rhs.as_query())
711 }
712
713 fn intersect<Rhs>(self, rhs: Rhs) -> crate::dsl::Intersect<Self, Rhs>
714 where
715 Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>,
716 {
717 CombinationClause::new(Intersect, Distinct, self, rhs.as_query())
718 }
719
720 fn intersect_all<Rhs>(self, rhs: Rhs) -> crate::dsl::IntersectAll<Self, Rhs>
721 where
722 Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>,
723 {
724 CombinationClause::new(Intersect, All, self, rhs.as_query())
725 }
726
727 fn except<Rhs>(self, rhs: Rhs) -> crate::dsl::Except<Self, Rhs>
728 where
729 Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>,
730 {
731 CombinationClause::new(Except, Distinct, self, rhs.as_query())
732 }
733
734 fn except_all<Rhs>(self, rhs: Rhs) -> crate::dsl::ExceptAll<Self, Rhs>
735 where
736 Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>,
737 {
738 CombinationClause::new(Except, All, self, rhs.as_query())
739 }
740}