(mut self)
| 139 | /// ``` |
| 140 | impl 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 |
no test coverage detected