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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
//! Database query filter utilities
//!
//! This module provides utility functions for building database query conditions,
//! including primary key handling, conditional bindings, and sorting functionality.
//! These functions are designed to work with the sqlx QueryBuilder to construct
//! safe and efficient database queries.
//!
//! 数据库查询过滤器工具
//!
//! 该模块提供了构建数据库查询条件的实用函数,
//! 包括主键处理、条件绑定功能。
//! 这些函数设计用于与 sqlx QueryBuilder 配合使用,以构建安全高效的数据库查询。
use FieldAccess;
use ;
use crate;
/// Push a primary key and value condition binding to the query builder
///
/// This function adds WHERE conditions for primary key columns with their corresponding values
/// to a query builder. It handles both single and composite primary keys.
///
/// # Type Parameters
/// * `ET` - The entity type that implements FieldAccess trait
/// * `DB` - The database type that implements the Database trait
/// * `VAL` - The value type that implements Encode and Type traits
///
/// # Arguments
/// * `qb` - Mutable reference to the QueryBuilder to modify
/// * `primary_key` - The PrimaryKey configuration containing column names
/// * `values` - Vector of values corresponding to the primary key columns
///
/// 推入主键和值的条件绑定到查询构建器
///
/// 此函数向查询构建器添加主键列及其对应值的 WHERE 条件。
/// 它处理单个主键和复合主键。
///
/// # 类型参数
/// * `ET` - 实现 FieldAccess trait 的实体类型
/// * `DB` - 实现 Database trait 的数据库类型
/// * `VAL` - 实现 Encode 和 Type traits 的值类型
///
/// # 参数
/// * `qb` - 要修改的 QueryBuilder 的可变引用
/// * `primary_key` - 包含列名的 PrimaryKey 配置
/// * `values` - 与主键列对应的值向量
/// Push entity and primary key conditions to the query builder
///
/// This function extracts values from an entity model based on primary key column names
/// and adds WHERE conditions to a query builder. It is useful for updating or deleting
/// records based on an entity instance.
///
/// # Type Parameters
/// * `ET` - The entity type that implements FieldAccess trait
/// * `DB` - The database type that implements the Database trait
/// * `VAL` - The value type that implements Encode, Type, ValueConvert, and Default traits
///
/// # Arguments
/// * `qb` - Mutable reference to the QueryBuilder to modify
/// * `model` - Reference to the entity model from which to extract values
/// * `primary_key` - The PrimaryKey configuration containing column names
///
/// 将实体和主键条件推送到查询构建器
///
/// 此函数根据主键列名从实体模型中提取值,并向查询构建器添加 WHERE 条件。
/// 它适用于基于实体实例更新或删除记录。
///
/// # 类型参数
/// * `ET` - 实现 FieldAccess trait 的实体类型
/// * `DB` - 实现 Database trait 的数据库类型
/// * `VAL` - 实现 Encode、Type、ValueConvert 和 Default traits 的值类型
///
/// # 参数
/// * `qb` - 要修改的 QueryBuilder 的可变引用
/// * `model` - 从中提取值的实体模型的引用
/// * `primary_key` - 包含列名的 PrimaryKey 配置