Skip to content

add support for SELECT .. ORDER BY ... #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/codegen/src/get_node_properties.rs
Original file line number Diff line number Diff line change
@@ -181,6 +181,10 @@ fn custom_handlers(node: &Node) -> TokenStream {
tokens.push(TokenProperty::from(Token::GroupP));
tokens.push(TokenProperty::from(Token::By));
}
if n.sort_clause.len() > 0 {
tokens.push(TokenProperty::from(Token::Order));
tokens.push(TokenProperty::from(Token::By));
}
match n.op() {
protobuf::SetOperation::Undefined => {},
protobuf::SetOperation::SetopNone => {},
14 changes: 14 additions & 0 deletions crates/parser/src/codegen.rs
Original file line number Diff line number Diff line change
@@ -106,6 +106,20 @@ mod tests {
)
}

#[test]
fn test_select_with_order_by() {
test_get_node_properties(
"SELECT a, b, c FROM table1 ORDER BY c;",
SyntaxKind::SelectStmt,
vec![
TokenProperty::from(SyntaxKind::Select),
TokenProperty::from(SyntaxKind::From),
TokenProperty::from(SyntaxKind::Order),
TokenProperty::from(SyntaxKind::By),
],
)
}

#[test]
fn test_create_domain() {
test_get_node_properties(