Skip to content

Commit 293133f

Browse files
authored
Merge pull request apache#313 from Jimexist/add-default-for-window-frame
add default value for window frame
2 parents 783bc21 + 950daf3 commit 293133f

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/ast/mod.rs

+24
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,19 @@ pub struct WindowFrame {
444444
// TBD: EXCLUDE
445445
}
446446

447+
impl Default for WindowFrame {
448+
/// returns default value for window frame
449+
///
450+
/// see https://www.sqlite.org/windowfunctions.html#frame_specifications
451+
fn default() -> Self {
452+
Self {
453+
units: WindowFrameUnits::Range,
454+
start_bound: WindowFrameBound::Preceding(None),
455+
end_bound: None,
456+
}
457+
}
458+
}
459+
447460
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
448461
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
449462
pub enum WindowFrameUnits {
@@ -1622,3 +1635,14 @@ impl fmt::Display for SqliteOnConflict {
16221635
}
16231636
}
16241637
}
1638+
1639+
#[cfg(test)]
1640+
mod tests {
1641+
use super::*;
1642+
1643+
#[test]
1644+
fn test_window_frame_default() {
1645+
let window_frame = WindowFrame::default();
1646+
assert_eq!(WindowFrameBound::Preceding(None), window_frame.start_bound);
1647+
}
1648+
}

tests/sqlparser_common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ fn parse_insert_sqlite() {
109109
.unwrap()
110110
{
111111
Statement::Insert { or, .. } => assert_eq!(or, expected_action),
112-
_ => panic!("{}", sql.to_string()),
112+
_ => panic!("{}", sql),
113113
};
114114

115115
let sql = "INSERT INTO test_table(id) VALUES(1)";

0 commit comments

Comments
 (0)