Skip to content

Commit ff7c221

Browse files
authored
Update expression docs (#894)
1 parent 0268460 commit ff7c221

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

src/expr.rs

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,32 @@
11
//! Building blocks of SQL statements.
22
//!
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.
45
//!
5-
//! [`SimpleExpr`] is the expression common among select fields, where clauses and many other places.
6+
//! [`ExprTrait`] provides "operator" methods for building expressions.
67
78
use crate::{func::*, query::*, types::*, value::*};
89

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`].
914
pub type Expr = SimpleExpr;
1015

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
1226
///
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.
1530
#[derive(Debug, Clone, PartialEq)]
1631
pub enum SimpleExpr {
1732
Column(ColumnRef),
@@ -42,11 +57,13 @@ pub enum SimpleExpr {
4257
/// # use sea_query::*;
4358
/// #
4459
/// let expr = 1_i32.cast_as("REAL");
45-
///
4660
/// let expr = Func::char_length("abc").eq(3_i32);
47-
///
4861
/// let expr = Expr::current_date().cast_as("TEXT").like("2024%");
4962
/// ```
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.
5067
pub trait ExprTrait: Sized {
5168
/// Express an arithmetic addition operation.
5269
///

0 commit comments

Comments
 (0)