|
1 | 1 | //! Building blocks of SQL statements.
|
2 | 2 | //!
|
3 |
| -//! [`Expr`] representing the primitive building block in the expressions. |
| 3 | +//! [`SimpleExpr`] is an arbitrary, dynamically-typed SQL expression. |
| 4 | +//! It can be used in select fields, where clauses and many other places. |
4 | 5 | //!
|
5 |
| -//! [`SimpleExpr`] is the expression common among select fields, where clauses and many other places. |
| 6 | +//! [`ExprTrait`] provides "operator" methods for building expressions. |
6 | 7 |
|
7 | 8 | use crate::{func::*, query::*, types::*, value::*};
|
8 | 9 |
|
| 10 | +/// A legacy compatibility alias for [`SimpleExpr`]. |
| 11 | +/// |
| 12 | +/// It used to be a separate type with constructor methods. |
| 13 | +/// Now you can call these constructors directly on [`SimpleExpr`]. |
9 | 14 | pub type Expr = SimpleExpr;
|
10 | 15 |
|
11 |
| -/// Represents a Simple Expression in SQL. |
| 16 | +/// An arbitrary, dynamically-typed SQL expression. |
| 17 | +/// |
| 18 | +/// It can be used in select fields, where clauses and many other places. |
| 19 | +/// |
| 20 | +/// More concreterly, under the hood [`SimpleExpr`]s can be: |
| 21 | +/// |
| 22 | +/// - Rust values |
| 23 | +/// - SQL identifiers |
| 24 | +/// - SQL function calls |
| 25 | +/// - various operators and sub-queries |
12 | 26 | ///
|
13 |
| -/// [`SimpleExpr`] is a node in the expression tree and can represent identifiers, function calls, |
14 |
| -/// various operators and sub-queries. |
| 27 | +/// If something is not supported here, look into [`BinOper::Custom`], |
| 28 | +/// [`Func::cust`], or [`Expr::cust*`][`Expr::cust_with_values`] as a |
| 29 | +/// workaround, and consider reporting your issue. |
15 | 30 | #[derive(Debug, Clone, PartialEq)]
|
16 | 31 | pub enum SimpleExpr {
|
17 | 32 | Column(ColumnRef),
|
@@ -42,11 +57,13 @@ pub enum SimpleExpr {
|
42 | 57 | /// # use sea_query::*;
|
43 | 58 | /// #
|
44 | 59 | /// let expr = 1_i32.cast_as("REAL");
|
45 |
| -/// |
46 | 60 | /// let expr = Func::char_length("abc").eq(3_i32);
|
47 |
| -/// |
48 | 61 | /// let expr = Expr::current_date().cast_as("TEXT").like("2024%");
|
49 | 62 | /// ```
|
| 63 | +/// |
| 64 | +/// If some methods are missing, look into [`BinOper::Custom`], [`Func::cust`], |
| 65 | +/// or [`Expr::cust*`][`Expr::cust_with_values`] as a workaround, and consider |
| 66 | +/// reporting your issue. |
50 | 67 | pub trait ExprTrait: Sized {
|
51 | 68 | /// Express an arithmetic addition operation.
|
52 | 69 | ///
|
|
0 commit comments