MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / into_condition

Method into_condition

src/entity/relation.rs:141–170  ·  view source on GitHub ↗
(mut self)

Source from the content-addressed store, hash-verified

139/// ```
140impl IntoCondition for RelationDef {
141 fn into_condition(mut self) -> Condition {
142 // Use table alias (if any) to construct the join condition
143 let from_tbl = match unpack_table_alias(&self.from_tbl) {
144 Some(alias) => alias,
145 None => unpack_table_ref(&self.from_tbl),
146 };
147 let to_tbl = match unpack_table_alias(&self.to_tbl) {
148 Some(alias) => alias,
149 None => unpack_table_ref(&self.to_tbl),
150 };
151 let owner_keys = self.from_col;
152 let foreign_keys = self.to_col;
153
154 let mut condition = match self.condition_type {
155 ConditionType::All => Condition::all(),
156 ConditionType::Any => Condition::any(),
157 };
158
159 condition = condition.add(join_tbl_on_condition(
160 SeaRc::clone(&from_tbl),
161 SeaRc::clone(&to_tbl),
162 owner_keys,
163 foreign_keys,
164 ));
165 if let Some(f) = self.on_condition.take() {
166 condition = condition.add(f(from_tbl, to_tbl));
167 }
168
169 condition
170 }
171}
172
173/// Defines a helper to build a relation

Callers 2

havingMethod · 0.80
filterMethod · 0.80

Calls 5

unpack_table_aliasFunction · 0.85
join_tbl_on_conditionFunction · 0.85
addMethod · 0.80
takeMethod · 0.80
unpack_table_refFunction · 0.50

Tested by

no test coverage detected