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