add default value for window frame

This commit is contained in:
Jiayu Liu 2021-06-03 14:17:23 +08:00 committed by Andrew Lamb
parent e548d38de8
commit 950daf39bb
2 changed files with 25 additions and 1 deletions

View file

@ -444,6 +444,19 @@ pub struct WindowFrame {
// TBD: EXCLUDE
}
impl Default for WindowFrame {
/// returns default value for window frame
///
/// see https://www.sqlite.org/windowfunctions.html#frame_specifications
fn default() -> Self {
Self {
units: WindowFrameUnits::Range,
start_bound: WindowFrameBound::Preceding(None),
end_bound: None,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum WindowFrameUnits {
@ -1622,3 +1635,14 @@ impl fmt::Display for SqliteOnConflict {
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_window_frame_default() {
let window_frame = WindowFrame::default();
assert_eq!(WindowFrameBound::Preceding(None), window_frame.start_bound);
}
}

View file

@ -109,7 +109,7 @@ fn parse_insert_sqlite() {
.unwrap()
{
Statement::Insert { or, .. } => assert_eq!(or, expected_action),
_ => panic!("{}", sql.to_string()),
_ => panic!("{}", sql),
};
let sql = "INSERT INTO test_table(id) VALUES(1)";