1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use crate;
/// Represents a `where` node in py_sql.
/// It's used to dynamically build the `WHERE` clause of a SQL query.
/// It will automatically prepend `WHERE` if needed and remove leading `AND` or `OR` keywords from its content.
///
/// # Example
///
/// PySQL syntax:
/// ```py
/// SELECT * FROM table
/// where:
/// if id != null:
/// AND id = #{id}
/// if name != null:
/// AND name = #{name}
/// ```
/// This would result in `SELECT * FROM table WHERE id = #{id} AND name = #{name}` (if both conditions are true),
/// or `SELECT * FROM table WHERE id = #{id}` (if only id is not null),
/// or `SELECT * FROM table WHERE name = #{name}` (if only name is not null).
/// If no conditions are met, the `WHERE` clause is omitted entirely.