drizzle_core/
traits.rs

1use crate::prelude::*;
2use core::any::Any;
3
4mod column;
5mod index;
6mod param;
7mod table;
8mod tuple;
9
10pub use column::*;
11pub use index::*;
12pub use param::*;
13pub use table::*;
14
15// Re-export enum traits from schema module
16pub use crate::schema::{AsEnumInfo, SQLEnumInfo};
17
18use crate::{SQL, ToSQL};
19
20pub trait SQLSchema<'a, T, V: SQLParam + 'a>: ToSQL<'a, V> {
21    const NAME: &'a str;
22    const TYPE: T;
23    const SQL: SQL<'a, V>;
24
25    // Optional runtime SQL generation for tables with dynamic constraints
26    fn sql(&self) -> SQL<'a, V> {
27        Self::SQL
28    }
29}
30
31pub trait SQLSchemaType: core::fmt::Debug + Any + Send + Sync {}
32
33pub trait SQLSchemaImpl: Any + Send + Sync {
34    fn create_statements(&self) -> Vec<String>;
35}
36
37/// Marker trait for types that can be compared in SQL expressions.
38pub trait SQLComparable<'a, V: SQLParam, Rhs> {}
39
40impl<'a, V, L, R> SQLComparable<'a, V, R> for L
41where
42    V: SQLParam + 'a,
43    L: ToSQL<'a, V>,
44    R: ToSQL<'a, V>,
45{
46}