@@ -35,17 +35,45 @@ pub enum Value {
35
35
/// `TIMESTAMP '...'` literals
36
36
Timestamp ( String ) ,
37
37
/// INTERVAL literals, roughly in the following format:
38
- /// `INTERVAL '<value>' <leading_field> [ (<leading_precision>) ]
39
- /// [ TO <last_field> [ (<fractional_seconds_precision>) ] ]`,
38
+ ///
39
+ /// ```
40
+ /// INTERVAL '<value>' <leading_field> [ (<leading_precision>) ]
41
+ /// [ TO <last_field> [ (<fractional_seconds_precision>) ] ]
42
+ /// ```
40
43
/// e.g. `INTERVAL '123:45.67' MINUTE(3) TO SECOND(2)`.
41
44
///
42
45
/// The parser does not validate the `<value>`, nor does it ensure
43
46
/// that the `<leading_field>` units >= the units in `<last_field>`,
44
47
/// so the user will have to reject intervals like `HOUR TO YEAR`.
45
48
Interval {
49
+ /// The raw [value] that was present in `INTERVAL '[value]'`
46
50
value : String ,
51
+ /// The unit of the first field in the interval. `INTERVAL 'T' MINUTE`
52
+ /// means `T` is in minutes
47
53
leading_field : DateTimeField ,
54
+ /// How many digits the leading field is allowed to occupy.
55
+ ///
56
+ /// The interval `INTERVAL '1234' MINUTE(3)` is **illegal**, but `INTERVAL
57
+ /// '123' MINUTE(3)` is fine.
58
+ ///
59
+ /// This parser does not do any validation that fields fit.
48
60
leading_precision : Option < u64 > ,
61
+ /// How much precision to keep track of
62
+ ///
63
+ /// If this is ommitted, then you are supposed to ignore all of the
64
+ /// non-lead fields. If it is less precise than the final field, you
65
+ /// are supposed to ignore the final field.
66
+ ///
67
+ /// For the following specifications:
68
+ ///
69
+ /// * `INTERVAL '1:1:1' HOURS TO SECONDS` the `last_field` gets
70
+ /// `Some(DateTimeField::Second)` and interpreters should generate an
71
+ /// interval equivalent to `3661` seconds.
72
+ /// * In `INTERVAL '1:1:1' HOURS` the `last_field` gets `None` and
73
+ /// interpreters should generate an interval equivalent to `3600`
74
+ /// seconds.
75
+ /// * In `INTERVAL '1:1:1' HOURS TO MINUTES` the interval should be
76
+ /// equivalent to `3660` seconds.
49
77
last_field : Option < DateTimeField > ,
50
78
/// The seconds precision can be specified in SQL source as
51
79
/// `INTERVAL '__' SECOND(_, x)` (in which case the `leading_field`
0 commit comments