• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

gluesql / gluesql / 19007449208

02 Nov 2025 04:42AM UTC coverage: 97.993% (-0.02%) from 98.015%
19007449208

push

github

web-flow
Merge pull request #1833 from moreal/clippy-manual-let-else

Resolves more clippy rules

clippy::manual_let_else
clippy::manual_string_new
clippy::manual_assert
clippy::from_iter_instead_of_collect
clippy::implicit_clone
clippy::inefficient_to_string
clippy::map_unwrap_or
clippy::needless_continue

279 of 304 new or added lines in 59 files covered. (91.78%)

2 existing lines in 2 files now uncovered.

39502 of 40311 relevant lines covered (97.99%)

73228.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.55
/core/src/executor/evaluate/expr.rs
1
use {
2
    super::{EvaluateError, Evaluated},
3
    crate::{
4
        ast::{AstLiteral, BinaryOperator, DataType, UnaryOperator},
5
        data::{Literal, Value},
6
        result::Result,
7
    },
8
    std::{borrow::Cow, cmp::Ordering},
9
};
10

11
pub fn literal(ast_literal: &AstLiteral) -> Result<Evaluated<'_>> {
6,581,067✔
12
    Literal::try_from(ast_literal).map(Evaluated::Literal)
6,581,067✔
13
}
6,581,067✔
14

15
pub fn typed_string<'a>(data_type: &'a DataType, value: Cow<'a, str>) -> Result<Evaluated<'a>> {
58,619✔
16
    let literal = Literal::Text(value);
58,619✔
17

18
    Value::try_from_literal(data_type, &literal).map(Evaluated::Value)
58,619✔
19
}
58,619✔
20

21
pub fn binary_op<'a>(
3,794,468✔
22
    op: &BinaryOperator,
3,794,468✔
23
    l: Evaluated<'a>,
3,794,468✔
24
    r: Evaluated<'a>,
3,794,468✔
25
) -> Result<Evaluated<'a>> {
3,794,468✔
26
    macro_rules! cmp {
27
        ($expr: expr) => {
28
            Ok(Evaluated::Value(Value::Bool($expr)))
29
        };
30
    }
31

32
    macro_rules! cond {
33
        (l $op: tt r) => {{
34
            let l: bool = l.try_into()?;
35
            let r: bool = r.try_into()?;
36
            let v = l $op r;
37

38
            Ok(Evaluated::Value(Value::Bool(v)))
39
        }};
40
    }
41

42
    if l.is_null() || r.is_null() {
3,794,468✔
43
        return Ok(Evaluated::Value(Value::Null));
67,456✔
44
    }
3,727,012✔
45

46
    match op {
3,727,012✔
47
        BinaryOperator::Plus => l.add(&r),
158,100✔
48
        BinaryOperator::Minus => l.subtract(&r),
93,432✔
49
        BinaryOperator::Multiply => l.multiply(&r),
79,696✔
50
        BinaryOperator::Divide => l.divide(&r),
64,804✔
51
        BinaryOperator::Modulo => l.modulo(&r),
52,360✔
52
        BinaryOperator::StringConcat => l.concat(r),
34,544✔
53
        BinaryOperator::Eq => Ok(Evaluated::from(l.evaluate_eq(&r))),
2,113,508✔
54
        BinaryOperator::NotEq => Ok(Evaluated::from(!l.evaluate_eq(&r))),
26,724✔
55
        BinaryOperator::Lt => cmp!(l.evaluate_cmp(&r) == Some(Ordering::Less)),
141,100✔
56
        BinaryOperator::LtEq => cmp!(matches!(
80,920✔
57
            l.evaluate_cmp(&r),
80,920✔
58
            Some(Ordering::Less) | Some(Ordering::Equal)
59
        )),
60
        BinaryOperator::Gt => cmp!(l.evaluate_cmp(&r) == Some(Ordering::Greater)),
236,504✔
61
        BinaryOperator::GtEq => cmp!(matches!(
64,124✔
62
            l.evaluate_cmp(&r),
64,124✔
63
            Some(Ordering::Greater) | Some(Ordering::Equal)
64
        )),
65
        BinaryOperator::And => cond!(l && r),
493,612✔
66
        BinaryOperator::Or => cond!(l || r),
28,560✔
67
        BinaryOperator::Xor => cond!(l ^ r),
3,808✔
68
        BinaryOperator::BitwiseAnd => l.bitwise_and(&r),
6,664✔
69
        BinaryOperator::BitwiseShiftLeft => l.bitwise_shift_left(&r),
4,760✔
70
        BinaryOperator::BitwiseShiftRight => l.bitwise_shift_right(&r),
4,760✔
71
        BinaryOperator::Arrow => l.arrow(&r),
39,032✔
72
    }
73
}
3,794,468✔
74

75
pub fn unary_op<'a>(op: &UnaryOperator, v: Evaluated<'a>) -> Result<Evaluated<'a>> {
264,248✔
76
    match op {
264,248✔
77
        UnaryOperator::Plus => v.unary_plus(),
44,812✔
78
        UnaryOperator::Minus => v.unary_minus(),
177,548✔
79
        UnaryOperator::Not => v.unary_not(),
15,232✔
80
        UnaryOperator::Factorial => v.unary_factorial(),
12,376✔
81
        UnaryOperator::BitwiseNot => v.unary_bitwise_not(),
14,280✔
82
    }
83
}
264,248✔
84

85
pub fn between<'a>(
43,792✔
86
    target: Evaluated<'a>,
43,792✔
87
    negated: bool,
43,792✔
88
    low: Evaluated<'a>,
43,792✔
89
    high: Evaluated<'a>,
43,792✔
90
) -> Result<Evaluated<'a>> {
43,792✔
91
    if target.is_null() || low.is_null() || high.is_null() {
43,792✔
92
        return Ok(Evaluated::Value(Value::Null));
15,232✔
93
    }
28,560✔
94

95
    let v = low.evaluate_cmp(&target) != Some(Ordering::Greater)
28,560✔
96
        && target.evaluate_cmp(&high) != Some(Ordering::Greater);
23,800✔
97
    let v = negated ^ v;
28,560✔
98

99
    Ok(Evaluated::Value(Value::Bool(v)))
28,560✔
100
}
43,792✔
101

102
pub fn array_index<'a>(obj: Evaluated<'a>, indexes: Vec<Evaluated<'a>>) -> Result<Evaluated<'a>> {
47,600✔
103
    let Evaluated::Value(value) = obj else {
47,600✔
NEW
104
        return Err(EvaluateError::MapOrListTypeRequired.into());
×
105
    };
106
    let indexes = indexes
47,600✔
107
        .into_iter()
47,600✔
108
        .map(Value::try_from)
47,600✔
109
        .collect::<Result<Vec<_>>>()?;
47,600✔
110
    value.selector_by_index(&indexes).map(Evaluated::Value)
47,600✔
111
}
47,600✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc