(
&self,
context: &mut Context,
out: &mut DynQuery,
function: &str,
args: &[&dyn Expression],
)
| 634 | } |
| 635 | } |
| 636 | UnaryOpType::Not => { |
| 637 | value.arg.write_query(self, context, out); |
| 638 | let Some(target) = out |
| 639 | .as_prepared::<MongoDBDriver>() |
| 640 | .and_then(MongoDBPrepared::current_bson) |
| 641 | else { |
| 642 | log::error!( |
| 643 | "Failed to get the bson in MongoDBSqlWriter::write_expression_unary_op after writing the argument" |
| 644 | ); |
| 645 | return; |
| 646 | }; |
| 647 | *target = doc! { "$not": [mem::take(target)] }.into(); |
| 648 | } |
| 649 | } |
| 650 | } |
| 651 | |
| 652 | fn write_binary_op( |
| 653 | &self, |
| 654 | context: &mut Context, |
| 655 | out: &mut AnyQuery, |
| 656 | value: &BinaryOp<&dyn Expression, &dyn Expression>, |
| 657 | ) { |
| 658 | match value.op { |
| 659 | BinaryOpType::ShiftLeft => { |
| 660 | return BinaryOp { |
| 661 | op: BinaryOpType::Multiplication, |
| 662 | lhs: value.lhs, |
| 663 | rhs: Operand::Call("POW", &[&Operand::LitInt(2), value.rhs]), |
| 664 | } |
| 665 | .write_query(self, context, out); |
| 666 | } |
| 667 | BinaryOpType::ShiftRight => { |
| 668 | return Operand::Call( |
| 669 | "FLOOR", |
| 670 | &[&BinaryOp { |
| 671 | op: BinaryOpType::Division, |
| 672 | lhs: value.lhs, |
| 673 | rhs: Operand::Call("POW", &[&Operand::LitInt(2), value.rhs]), |
| 674 | }], |
| 675 | ) |
| 676 | .write_query(self, context, out); |
| 677 | } |
| 678 | BinaryOpType::NotLike | BinaryOpType::NotRegexp | BinaryOpType::NotGlob => { |
| 679 | return UnaryOp { |
| 680 | op: UnaryOpType::Not, |
| 681 | arg: BinaryOp { |
| 682 | op: match value.op { |
| 683 | BinaryOpType::NotLike => BinaryOpType::Like, |
| 684 | BinaryOpType::NotRegexp => BinaryOpType::Regexp, |
| 685 | BinaryOpType::NotGlob => BinaryOpType::Glob, |
| 686 | _ => { |
| 687 | log::error!("Unexpected negated binary operation"); |
| 688 | BinaryOpType::Glob |
| 689 | } |
| 690 | }, |
| 691 | lhs: value.lhs, |
| 692 | rhs: value.rhs, |
| 693 | }, |
nothing calls this directly
no test coverage detected