drizzle_core/builder.rs
1pub mod conflict;
2pub mod states;
3
4pub use conflict::*;
5pub use states::*;
6
7/// Marker trait for executable builder states.
8///
9/// This is an extension point for driver crates to opt in builder state
10/// markers that represent complete, executable queries (for example, to
11/// enable set operations or prepared statements on those states).
12pub trait ExecutableState {}
13
14#[derive(Debug, Clone)]
15pub struct BuilderInit;
16
17impl ExecutableState for BuilderInit {}
18
19// =============================================================================
20// Capability marker traits for typestate method gating
21// =============================================================================
22// These allow a single generic impl block per method instead of duplicating
23// across every state that supports it.
24//
25// Used directly by the inner `SelectBuilder` impls in driver crates.
26// Wrapper builders (`DrizzleBuilder`, `TransactionBuilder`) use a declarative
27// macro to stamp out per-state impls instead, because Rust's inherent impl
28// overlap rules prevent trait-gated generics when other builder types
29// (insert/update/delete) define methods with the same name.
30
31/// States where `.where()` is available.
32pub trait WhereAllowed {}
33
34/// States where `.group_by()` is available.
35pub trait GroupByAllowed {}
36
37/// States where `.order_by()` is available.
38pub trait OrderByAllowed {}
39
40/// States where `.limit()` is available.
41pub trait LimitAllowed {}
42
43/// States where `.offset()` is available.
44pub trait OffsetAllowed {}
45
46/// States where `.join()` and variant joins are available.
47pub trait JoinAllowed {}
48
49/// States where `.having()` is available (requires GROUP BY).
50pub trait HavingAllowed {}
51
52/// States where GROUP BY has been applied (allows mixed agg/scalar selects).
53#[diagnostic::on_unimplemented(
54 message = "SELECT mixes aggregate and non-aggregate expressions without GROUP BY",
55 label = "add .group_by(...) before executing this query"
56)]
57pub trait GroupByApplied {}