1#![allow(unused_variables, clippy::unused_self, clippy::wrong_self_convention)]
2
3use std::marker::PhantomData;
4
5const STUB: &str = "cartel_sqlite: DSL stub only callable inside #[query] body";
6
7pub struct FilterBuilder<T>(PhantomData<T>);
8
9pub struct JoinBuilder2<P, J>(PhantomData<(P, J)>);
10pub type JoinBuilder<P, J> = JoinBuilder2<P, J>;
11pub struct JoinBuilder3<A, B, C>(PhantomData<(A, B, C)>);
12pub struct JoinBuilder4<A, B, C, D>(PhantomData<(A, B, C, D)>);
13
14pub struct Joined2Filter<A, B>(PhantomData<(A, B)>);
15pub struct Joined3Filter<A, B, C>(PhantomData<(A, B, C)>);
16pub struct Joined4Filter<A, B, C, D>(PhantomData<(A, B, C, D)>);
17
18pub struct AggBuilder<T, K>(PhantomData<(T, K)>);
19
20pub struct InsertBuilder<T>(PhantomData<T>);
21pub struct UpdateBuilder<T>(PhantomData<T>);
22pub struct DeleteBuilder<T>(PhantomData<T>);
23pub struct ConflictTarget<T>(PhantomData<T>);
24pub struct Cte<T>(PhantomData<T>);
25pub struct SelectBuilder<R>(PhantomData<R>);
26pub struct AggHandle(());
27
28pub struct RowIter<T>(PhantomData<T>);
29
30pub trait SourceRow {
31 type Row;
32}
33impl<T> SourceRow for FilterBuilder<T> {
34 type Row = T;
35}
36impl<T> SourceRow for Cte<T> {
37 type Row = T;
38}
39impl<R> SourceRow for SelectBuilder<R> {
40 type Row = R;
41}
42
43impl<T> FilterBuilder<T> {
44 #[doc(hidden)]
45 pub fn __new() -> Self {
46 Self(PhantomData)
47 }
48
49 pub fn one(self) -> T {
50 unreachable!("{STUB}")
51 }
52 pub fn first(self) -> Option<T> {
53 unreachable!("{STUB}")
54 }
55 pub fn all(self) -> Vec<T> {
56 unreachable!("{STUB}")
57 }
58 pub fn stream(self) -> RowIter<T> {
59 unreachable!("{STUB}")
60 }
61
62 pub fn count(self) -> i64 {
63 unreachable!("{STUB}")
64 }
65 pub fn sum<F, U, R>(self, f: F) -> Option<R>
66 where
67 F: FnOnce(T) -> U,
68 {
69 unreachable!("{STUB}")
70 }
71 pub fn avg<F, U, R>(self, f: F) -> Option<R>
72 where
73 F: FnOnce(T) -> U,
74 {
75 unreachable!("{STUB}")
76 }
77 pub fn min<F, U, R>(self, f: F) -> Option<R>
78 where
79 F: FnOnce(T) -> U,
80 {
81 unreachable!("{STUB}")
82 }
83 pub fn max<F, U, R>(self, f: F) -> Option<R>
84 where
85 F: FnOnce(T) -> U,
86 {
87 unreachable!("{STUB}")
88 }
89
90 pub fn group_by<F, K>(self, f: F) -> AggBuilder<T, K>
91 where
92 F: FnOnce(T) -> K,
93 {
94 unreachable!("{STUB}")
95 }
96
97 pub fn order_by<F, U>(self, f: F) -> Self
98 where
99 F: FnOnce(T) -> U,
100 {
101 unreachable!("{STUB}")
102 }
103 pub fn order_by_desc<F, U>(self, f: F) -> Self
104 where
105 F: FnOnce(T) -> U,
106 {
107 unreachable!("{STUB}")
108 }
109 pub fn limit(self, n: i64) -> Self {
110 unreachable!("{STUB}")
111 }
112 pub fn offset(self, n: i64) -> Self {
113 unreachable!("{STUB}")
114 }
115 pub fn distinct(self) -> Self {
116 unreachable!("{STUB}")
117 }
118
119 pub fn update<F>(self, f: F) -> UpdateBuilder<T>
120 where
121 F: FnOnce(&mut T),
122 {
123 unreachable!("{STUB}")
124 }
125 pub fn delete(self) -> DeleteBuilder<T> {
126 unreachable!("{STUB}")
127 }
128
129 pub fn union(self, other: Self) -> Self {
130 unreachable!("{STUB}")
131 }
132 pub fn union_all(self, other: Self) -> Self {
133 unreachable!("{STUB}")
134 }
135 pub fn intersect(self, other: Self) -> Self {
136 unreachable!("{STUB}")
137 }
138 pub fn except(self, other: Self) -> Self {
139 unreachable!("{STUB}")
140 }
141
142 pub fn cte(self) -> Cte<T> {
143 unreachable!("{STUB}")
144 }
145
146 pub fn select<F, R>(self, f: F) -> SelectBuilder<R>
147 where
148 F: FnOnce(T) -> R,
149 {
150 unreachable!("{STUB}")
151 }
152}
153
154impl<T, K> AggBuilder<T, K> {
155 pub fn count(self) -> Vec<(K, i64)> {
156 unreachable!("{STUB}")
157 }
158 pub fn sum<F, U>(self, f: F) -> Vec<(K, Option<U>)>
159 where
160 F: FnOnce(T) -> U,
161 {
162 unreachable!("{STUB}")
163 }
164 pub fn avg<F, U>(self, f: F) -> Vec<(K, Option<f64>)>
165 where
166 F: FnOnce(T) -> U,
167 {
168 unreachable!("{STUB}")
169 }
170 pub fn min<F, U>(self, f: F) -> Vec<(K, Option<U>)>
171 where
172 F: FnOnce(T) -> U,
173 {
174 unreachable!("{STUB}")
175 }
176 pub fn max<F, U>(self, f: F) -> Vec<(K, Option<U>)>
177 where
178 F: FnOnce(T) -> U,
179 {
180 unreachable!("{STUB}")
181 }
182
183 pub fn having<F>(self, f: F) -> Self
184 where
185 F: FnOnce(T, AggHandle) -> bool,
186 {
187 unreachable!("{STUB}")
188 }
189
190 pub fn order_by<F, U>(self, f: F) -> Self
191 where
192 F: FnOnce(T) -> U,
193 {
194 unreachable!("{STUB}")
195 }
196 pub fn order_by_desc<F, U>(self, f: F) -> Self
197 where
198 F: FnOnce(T) -> U,
199 {
200 unreachable!("{STUB}")
201 }
202 pub fn limit(self, n: i64) -> Self {
203 unreachable!("{STUB}")
204 }
205 pub fn offset(self, n: i64) -> Self {
206 unreachable!("{STUB}")
207 }
208}
209
210impl<A, B> JoinBuilder2<A, B> {
211 pub fn filter(self, f: impl FnOnce(A, B) -> bool) -> Joined2Filter<A, B> {
212 unreachable!("{STUB}")
213 }
214 pub fn join<C>(self, f: impl FnOnce(A, B, C) -> bool) -> JoinBuilder3<A, B, C> {
215 unreachable!("{STUB}")
216 }
217 pub fn left_join<C>(self, f: impl FnOnce(A, B, C) -> bool) -> JoinBuilder3<A, B, C> {
218 unreachable!("{STUB}")
219 }
220 pub fn right_join<C>(self, f: impl FnOnce(A, B, C) -> bool) -> JoinBuilder3<A, B, C> {
221 unreachable!("{STUB}")
222 }
223 pub fn full_join<C>(self, f: impl FnOnce(A, B, C) -> bool) -> JoinBuilder3<A, B, C> {
224 unreachable!("{STUB}")
225 }
226}
227
228impl<A, B, C> JoinBuilder3<A, B, C> {
229 pub fn filter(self, f: impl FnOnce(A, B, C) -> bool) -> Joined3Filter<A, B, C> {
230 unreachable!("{STUB}")
231 }
232 pub fn join<D>(self, f: impl FnOnce(A, B, C, D) -> bool) -> JoinBuilder4<A, B, C, D> {
233 unreachable!("{STUB}")
234 }
235 pub fn left_join<D>(self, f: impl FnOnce(A, B, C, D) -> bool) -> JoinBuilder4<A, B, C, D> {
236 unreachable!("{STUB}")
237 }
238 pub fn right_join<D>(self, f: impl FnOnce(A, B, C, D) -> bool) -> JoinBuilder4<A, B, C, D> {
239 unreachable!("{STUB}")
240 }
241 pub fn full_join<D>(self, f: impl FnOnce(A, B, C, D) -> bool) -> JoinBuilder4<A, B, C, D> {
242 unreachable!("{STUB}")
243 }
244}
245
246impl<A, B, C, D> JoinBuilder4<A, B, C, D> {
247 pub fn filter(self, f: impl FnOnce(A, B, C, D) -> bool) -> Joined4Filter<A, B, C, D> {
248 unreachable!("{STUB}")
249 }
250}
251
252impl<A, B> Joined2Filter<A, B> {
253 pub fn one<R>(self) -> R {
254 unreachable!("{STUB}")
255 }
256 pub fn first<R>(self) -> Option<R> {
257 unreachable!("{STUB}")
258 }
259 pub fn all<R>(self) -> Vec<R> {
260 unreachable!("{STUB}")
261 }
262 pub fn stream<R>(self) -> RowIter<R> {
263 unreachable!("{STUB}")
264 }
265 pub fn count(self) -> i64 {
266 unreachable!("{STUB}")
267 }
268 pub fn order_by<F, U>(self, f: F) -> Self
269 where
270 F: FnOnce(A, B) -> U,
271 {
272 unreachable!("{STUB}")
273 }
274 pub fn order_by_desc<F, U>(self, f: F) -> Self
275 where
276 F: FnOnce(A, B) -> U,
277 {
278 unreachable!("{STUB}")
279 }
280 pub fn limit(self, n: i64) -> Self {
281 unreachable!("{STUB}")
282 }
283 pub fn offset(self, n: i64) -> Self {
284 unreachable!("{STUB}")
285 }
286 pub fn distinct(self) -> Self {
287 unreachable!("{STUB}")
288 }
289 pub fn update(self, f: impl FnOnce(&mut A, B)) -> UpdateBuilder<A> {
290 unreachable!("{STUB}")
291 }
292 pub fn delete(self) -> DeleteBuilder<A> {
293 unreachable!("{STUB}")
294 }
295 pub fn select<F, R>(self, _f: F) -> SelectBuilder<R>
296 where
297 F: FnOnce(A, B) -> R,
298 {
299 unreachable!("{STUB}")
300 }
301}
302
303impl<A, B, C> Joined3Filter<A, B, C> {
304 pub fn one<R>(self) -> R {
305 unreachable!("{STUB}")
306 }
307 pub fn first<R>(self) -> Option<R> {
308 unreachable!("{STUB}")
309 }
310 pub fn all<R>(self) -> Vec<R> {
311 unreachable!("{STUB}")
312 }
313 pub fn stream<R>(self) -> RowIter<R> {
314 unreachable!("{STUB}")
315 }
316 pub fn count(self) -> i64 {
317 unreachable!("{STUB}")
318 }
319 pub fn order_by<F, U>(self, f: F) -> Self
320 where
321 F: FnOnce(A, B, C) -> U,
322 {
323 unreachable!("{STUB}")
324 }
325 pub fn order_by_desc<F, U>(self, f: F) -> Self
326 where
327 F: FnOnce(A, B, C) -> U,
328 {
329 unreachable!("{STUB}")
330 }
331 pub fn limit(self, n: i64) -> Self {
332 unreachable!("{STUB}")
333 }
334 pub fn offset(self, n: i64) -> Self {
335 unreachable!("{STUB}")
336 }
337 pub fn distinct(self) -> Self {
338 unreachable!("{STUB}")
339 }
340 pub fn update(self, f: impl FnOnce(&mut A, B, C)) -> UpdateBuilder<A> {
341 unreachable!("{STUB}")
342 }
343 pub fn delete(self) -> DeleteBuilder<A> {
344 unreachable!("{STUB}")
345 }
346 pub fn select<F, R>(self, _f: F) -> SelectBuilder<R>
347 where
348 F: FnOnce(A, B, C) -> R,
349 {
350 unreachable!("{STUB}")
351 }
352}
353
354impl<A, B, C, D> Joined4Filter<A, B, C, D> {
355 pub fn one<R>(self) -> R {
356 unreachable!("{STUB}")
357 }
358 pub fn first<R>(self) -> Option<R> {
359 unreachable!("{STUB}")
360 }
361 pub fn all<R>(self) -> Vec<R> {
362 unreachable!("{STUB}")
363 }
364 pub fn stream<R>(self) -> RowIter<R> {
365 unreachable!("{STUB}")
366 }
367 pub fn count(self) -> i64 {
368 unreachable!("{STUB}")
369 }
370 pub fn order_by<F, U>(self, f: F) -> Self
371 where
372 F: FnOnce(A, B, C, D) -> U,
373 {
374 unreachable!("{STUB}")
375 }
376 pub fn order_by_desc<F, U>(self, f: F) -> Self
377 where
378 F: FnOnce(A, B, C, D) -> U,
379 {
380 unreachable!("{STUB}")
381 }
382 pub fn limit(self, n: i64) -> Self {
383 unreachable!("{STUB}")
384 }
385 pub fn offset(self, n: i64) -> Self {
386 unreachable!("{STUB}")
387 }
388 pub fn distinct(self) -> Self {
389 unreachable!("{STUB}")
390 }
391 pub fn update(self, f: impl FnOnce(&mut A, B, C, D)) -> UpdateBuilder<A> {
392 unreachable!("{STUB}")
393 }
394 pub fn delete(self) -> DeleteBuilder<A> {
395 unreachable!("{STUB}")
396 }
397 pub fn select<F, R>(self, _f: F) -> SelectBuilder<R>
398 where
399 F: FnOnce(A, B, C, D) -> R,
400 {
401 unreachable!("{STUB}")
402 }
403}
404
405impl<T> InsertBuilder<T> {
406 pub fn returning_one(self) -> T {
407 unreachable!("{STUB}")
408 }
409 pub fn returning_first(self) -> Option<T> {
410 unreachable!("{STUB}")
411 }
412 pub fn returning_all(self) -> Vec<T> {
413 unreachable!("{STUB}")
414 }
415 pub fn on_conflict_do_nothing(self) -> Self {
416 unreachable!("{STUB}")
417 }
418 pub fn on_conflict<F, U>(self, f: F) -> ConflictTarget<T>
419 where
420 F: FnOnce(T) -> U,
421 {
422 unreachable!("{STUB}")
423 }
424}
425
426impl<T> ConflictTarget<T> {
427 pub fn do_nothing(self) -> InsertBuilder<T> {
428 unreachable!("{STUB}")
429 }
430 pub fn do_update<F>(self, f: F) -> InsertBuilder<T>
431 where
432 F: FnOnce(&mut T),
433 {
434 unreachable!("{STUB}")
435 }
436}
437
438impl<T> UpdateBuilder<T> {
439 pub fn returning_one(self) -> T {
440 unreachable!("{STUB}")
441 }
442 pub fn returning_first(self) -> Option<T> {
443 unreachable!("{STUB}")
444 }
445 pub fn returning_all(self) -> Vec<T> {
446 unreachable!("{STUB}")
447 }
448}
449
450impl<T> DeleteBuilder<T> {
451 pub fn returning_one(self) -> T {
452 unreachable!("{STUB}")
453 }
454 pub fn returning_first(self) -> Option<T> {
455 unreachable!("{STUB}")
456 }
457 pub fn returning_all(self) -> Vec<T> {
458 unreachable!("{STUB}")
459 }
460}
461
462impl<T> Cte<T> {
463 pub fn filter<F>(self, f: F) -> FilterBuilder<T>
464 where
465 F: FnOnce(T) -> bool,
466 {
467 unreachable!("{STUB}")
468 }
469 pub fn all(self) -> Vec<T> {
470 unreachable!("{STUB}")
471 }
472 pub fn one(self) -> T {
473 unreachable!("{STUB}")
474 }
475 pub fn first(self) -> Option<T> {
476 unreachable!("{STUB}")
477 }
478 pub fn stream(self) -> RowIter<T> {
479 unreachable!("{STUB}")
480 }
481 pub fn union(self, other: Self) -> Self {
482 unreachable!("{STUB}")
483 }
484 pub fn union_all(self, other: Self) -> Self {
485 unreachable!("{STUB}")
486 }
487 pub fn intersect(self, other: Self) -> Self {
488 unreachable!("{STUB}")
489 }
490 pub fn except(self, other: Self) -> Self {
491 unreachable!("{STUB}")
492 }
493}
494
495impl<R> SelectBuilder<R> {
496 pub fn one(self) -> R {
497 unreachable!("{STUB}")
498 }
499 pub fn first(self) -> Option<R> {
500 unreachable!("{STUB}")
501 }
502 pub fn all(self) -> Vec<R> {
503 unreachable!("{STUB}")
504 }
505 pub fn stream(self) -> RowIter<R> {
506 unreachable!("{STUB}")
507 }
508}
509
510impl AggHandle {
511 pub fn count(&self) -> i64 {
512 unreachable!("{STUB}")
513 }
514 pub fn sum<U>(&self, col: U) -> Option<U> {
515 unreachable!("{STUB}")
516 }
517 pub fn avg<U>(&self, col: U) -> Option<f64> {
518 unreachable!("{STUB}")
519 }
520 pub fn min<U>(&self, col: U) -> Option<U> {
521 unreachable!("{STUB}")
522 }
523 pub fn max<U>(&self, col: U) -> Option<U> {
524 unreachable!("{STUB}")
525 }
526}
527
528pub trait Text: Sized {
529 fn like<S: AsRef<str>>(self, pattern: S) -> bool {
530 unreachable!("{STUB}")
531 }
532 fn not_like<S: AsRef<str>>(self, pattern: S) -> bool {
533 unreachable!("{STUB}")
534 }
535 fn glob<S: AsRef<str>>(self, pattern: S) -> bool {
536 unreachable!("{STUB}")
537 }
538 fn concat<S: AsRef<str>>(self, other: S) -> String {
539 unreachable!("{STUB}")
540 }
541}
542impl Text for String {}
543impl Text for &str {}
544impl Text for Option<String> {}
545
546pub fn exists<S>(subquery: S) -> bool {
547 unreachable!("{STUB}")
548}
549pub fn not_exists<S>(subquery: S) -> bool {
550 unreachable!("{STUB}")
551}
552
553pub struct WindowExpr<T>(PhantomData<T>);
554pub struct WindowSpec(());
555
556impl<T> WindowExpr<T> {
557 pub fn over<F>(self, _f: F) -> T
558 where
559 F: FnOnce(WindowSpec) -> WindowSpec,
560 {
561 unreachable!("{STUB}")
562 }
563}
564
565impl WindowSpec {
566 pub fn partition_by<U>(self, _col: U) -> Self {
567 unreachable!("{STUB}")
568 }
569 pub fn order_by<U>(self, _col: U) -> Self {
570 unreachable!("{STUB}")
571 }
572 pub fn order_by_desc<U>(self, _col: U) -> Self {
573 unreachable!("{STUB}")
574 }
575}
576
577pub fn row_number() -> WindowExpr<i64> {
578 unreachable!("{STUB}")
579}
580pub fn rank() -> WindowExpr<i64> {
581 unreachable!("{STUB}")
582}
583pub fn dense_rank() -> WindowExpr<i64> {
584 unreachable!("{STUB}")
585}
586pub fn count<T>(_x: T) -> WindowExpr<i64> {
587 unreachable!("{STUB}")
588}
589pub fn sum<T, R>(_x: T) -> WindowExpr<R> {
590 unreachable!("{STUB}")
591}
592pub fn avg<T, R>(_x: T) -> WindowExpr<R> {
593 unreachable!("{STUB}")
594}
595pub fn min<T, R>(_x: T) -> WindowExpr<R> {
596 unreachable!("{STUB}")
597}
598pub fn max<T, R>(_x: T) -> WindowExpr<R> {
599 unreachable!("{STUB}")
600}