MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / collect_pk_equalities

Function collect_pk_equalities

nodedb-sql/src/planner/dml_helpers.rs:166–204  ·  view source on GitHub ↗
(expr: &ast::Expr, pk: &str, keys: &mut Vec<SqlValue>)

Source from the content-addressed store, hash-verified

164}
165
166fn collect_pk_equalities(expr: &ast::Expr, pk: &str, keys: &mut Vec<SqlValue>) {
167 match expr {
168 ast::Expr::BinaryOp {
169 left,
170 op: ast::BinaryOperator::Eq,
171 right,
172 } => {
173 if is_column(left, pk)
174 && let Ok(v) = expr_to_sql_value(right)
175 {
176 keys.push(v);
177 } else if is_column(right, pk)
178 && let Ok(v) = expr_to_sql_value(left)
179 {
180 keys.push(v);
181 }
182 }
183 ast::Expr::BinaryOp {
184 left,
185 op: ast::BinaryOperator::Or,
186 right,
187 } => {
188 collect_pk_equalities(left, pk, keys);
189 collect_pk_equalities(right, pk, keys);
190 }
191 ast::Expr::InList {
192 expr: inner,
193 list,
194 negated: false,
195 } if is_column(inner, pk) => {
196 for item in list {
197 if let Ok(v) = expr_to_sql_value(item) {
198 keys.push(v);
199 }
200 }
201 }
202 _ => {}
203 }
204}
205
206fn is_column(expr: &ast::Expr, name: &str) -> bool {
207 match expr {

Callers 1

extract_point_keysFunction · 0.85

Calls 3

is_columnFunction · 0.85
expr_to_sql_valueFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected