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

flowlight0 / simpledb-rs / #117

21 Jun 2025 08:31AM UTC coverage: 78.843% (+0.04%) from 78.799%
#117

push

web-flow
Implement AS keyword support with ExtendPlan (#124)

* Refine QueryData constructors

* Refactor

25 of 37 new or added lines in 4 files covered. (67.57%)

2 existing lines in 1 file now uncovered.

2944 of 3734 relevant lines covered (78.84%)

1.67 hits per line

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

69.23
/src/parser/statement.rs
1
use crate::record::field::{Spec, Value};
2

3
use super::predicate::{Expression, Predicate};
4

5
#[derive(Debug, PartialEq, Eq)]
6
pub enum Statement {
7
    Query(QueryData),
8
    UpdateCommand(UpdateCommand),
9
}
10

11
#[derive(Debug, PartialEq, Eq)]
12
pub struct QueryData {
13
    pub fields: Option<Vec<String>>, // None means all fields
14
    pub tables: Vec<String>,
15
    pub predicate: Option<Predicate>,
16
    pub order_by: Option<Vec<String>>, // None means no ordering
17
    pub extend_fields: Vec<(Expression, String)>,
18
}
19

20
impl QueryData {
21
    pub fn new(fields: Vec<String>, tables: Vec<String>, predicate: Option<Predicate>) -> Self {
1✔
22
        QueryData::new_with_order_and_extend(fields, tables, predicate, None, vec![])
1✔
23
    }
24

25
    pub fn new_all(tables: Vec<String>, predicate: Option<Predicate>) -> Self {
1✔
26
        QueryData::new_all_with_order(tables, predicate, None)
1✔
27
    }
28

UNCOV
29
    pub fn new_with_order(
×
30
        fields: Vec<String>,
31
        tables: Vec<String>,
32
        predicate: Option<Predicate>,
33
        order_by: Option<Vec<String>>,
34
    ) -> Self {
35
        QueryData {
UNCOV
36
            fields: Some(fields),
×
37
            tables,
38
            predicate,
39
            order_by,
NEW
40
            extend_fields: Vec::new(),
×
41
        }
42
    }
43

44
    pub fn new_all_with_order(
1✔
45
        tables: Vec<String>,
46
        predicate: Option<Predicate>,
47
        order_by: Option<Vec<String>>,
48
    ) -> Self {
49
        QueryData {
50
            fields: None,
51
            tables,
52
            predicate,
53
            order_by,
54
            extend_fields: Vec::new(),
1✔
55
        }
56
    }
57

58
    pub fn new_with_order_and_extend(
2✔
59
        fields: Vec<String>,
60
        tables: Vec<String>,
61
        predicate: Option<Predicate>,
62
        order_by: Option<Vec<String>>,
63
        extend_fields: Vec<(Expression, String)>,
64
    ) -> Self {
65
        QueryData {
66
            fields: Some(fields),
2✔
67
            tables,
68
            predicate,
69
            order_by,
70
            extend_fields,
71
        }
72
    }
73

NEW
74
    pub fn new_all_with_order_and_extend(
×
75
        tables: Vec<String>,
76
        predicate: Option<Predicate>,
77
        order_by: Option<Vec<String>>,
78
        extend_fields: Vec<(Expression, String)>,
79
    ) -> Self {
80
        QueryData {
81
            fields: None,
82
            tables,
83
            predicate,
84
            order_by,
85
            extend_fields,
86
        }
87
    }
88
}
89

90
#[derive(Debug, PartialEq, Eq)]
91
pub enum UpdateCommand {
92
    Insert(String, Vec<String>, Vec<Value>),
93
    Delete(String, Option<Predicate>),
94
    Modify(String, String, Expression, Option<Predicate>),
95
    Create(CreateCommand),
96
}
97

98
#[derive(Debug, PartialEq, Eq)]
99
pub enum CreateCommand {
100
    Table(String, Vec<FieldDefinition>),
101
    View(String, QueryData),
102
    Index(String, String, String),
103
}
104

105
#[derive(Debug, PartialEq, Eq)]
106
pub struct FieldDefinition {
107
    pub name: String,
108
    pub field_type: Spec,
109
}
110

111
impl FieldDefinition {
112
    pub fn new(name: String, field_type: Spec) -> Self {
3✔
113
        FieldDefinition { name, field_type }
114
    }
115
}
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

© 2025 Coveralls, Inc