(
&self,
context: &mut Context,
out: &mut DynQuery,
value: &BinaryOp<&dyn Expression, &dyn Expression>,
)
| 518 | return BinaryOp { |
| 519 | op: BinaryOpType::Multiplication, |
| 520 | lhs: value.lhs, |
| 521 | rhs: Operand::Call("POW", &[&Operand::LitInt(2), value.rhs]), |
| 522 | } |
| 523 | .write_query(self, context, out); |
| 524 | } |
| 525 | BinaryOpType::ShiftRight => { |
| 526 | return Operand::Call( |
| 527 | "FLOOR", |
| 528 | &[&BinaryOp { |
| 529 | op: BinaryOpType::Division, |
| 530 | lhs: value.lhs, |
| 531 | rhs: Operand::Call("POW", &[&Operand::LitInt(2), value.rhs]), |
| 532 | }], |
| 533 | ) |
| 534 | .write_query(self, context, out); |
| 535 | } |
| 536 | BinaryOpType::NotLike | BinaryOpType::NotRegexp | BinaryOpType::NotGlob => { |
| 537 | return UnaryOp { |
| 538 | op: UnaryOpType::Not, |
| 539 | arg: BinaryOp { |
| 540 | op: match value.op { |
| 541 | BinaryOpType::NotLike => BinaryOpType::Like, |
| 542 | BinaryOpType::NotRegexp => BinaryOpType::Regexp, |
| 543 | BinaryOpType::NotGlob => BinaryOpType::Glob, |
| 544 | _ => unreachable!(), |
| 545 | }, |
| 546 | lhs: value.lhs, |
| 547 | rhs: value.rhs, |
| 548 | }, |
| 549 | } |
| 550 | .write_query(self, context, out); |
| 551 | } |
| 552 | BinaryOpType::Alias => return value.lhs.write_query(self, context, out), |
| 553 | _ => {} |
| 554 | } |
| 555 | let Some(document) = out |
| 556 | .as_prepared::<MongoDBDriver>() |
| 557 | .and_then(MongoDBPrepared::switch_to_document) |
| 558 | else { |
| 559 | log::error!( |
| 560 | "The query provided to write_expression_binary_op (out) does not have a document to write the content into" |
| 561 | ); |
| 562 | return; |
| 563 | }; |
| 564 | let lhs = { |
| 565 | let mut lhs = MongoDBSqlWriter::make_prepared(); |
| 566 | value.lhs.write_query(self, context, &mut lhs); |
| 567 | let Some(lhs) = lhs |
| 568 | .as_prepared::<MongoDBDriver>() |
| 569 | .and_then(MongoDBPrepared::current_bson) |
| 570 | .map(mem::take) |
| 571 | else { |
| 572 | log::error!( |
| 573 | "Unexpected error while rendering the lhs of the binary expression, failed to get the bson object" |
| 574 | ); |
| 575 | return; |
| 576 | }; |
| 577 | lhs |
no test coverage detected