Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
source: crates/squawk_syntax/src/test.rs
input_file: crates/squawk_syntax/test_data/validation/non_standard_param.sql
---
SOURCE_FILE@0..47
COMMENT@0..21 "-- invalid param type"
WHITESPACE@21..22 "\n"
SELECT@22..31
SELECT_CLAUSE@22..31
SELECT_KW@22..28 "select"
WHITESPACE@28..29 " "
TARGET_LIST@29..31
TARGET@29..31
NON_STANDARD_PARAM@29..31
COLON@29..30 ":"
NAME_REF@30..31
IDENT@30..31 "x"
SEMICOLON@31..32 ";"
WHITESPACE@32..33 "\n"
SELECT@33..45
SELECT_CLAUSE@33..45
SELECT_KW@33..39 "select"
WHITESPACE@39..40 " "
TARGET_LIST@40..45
TARGET@40..45
NON_STANDARD_PARAM@40..45
COLON@40..41 ":"
WHITESPACE@41..42 " "
NAME_REF@42..45
IDENT@42..45 "foo"
SEMICOLON@45..46 ";"
WHITESPACE@46..47 "\n"

ERROR@29:31 "Invalid parameter type. Use positional params like $1 instead."
ERROR@40:45 "Invalid parameter type. Use positional params like $1 instead."
8 changes: 8 additions & 0 deletions crates/squawk_syntax/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub(crate) fn validate(root: &SyntaxNode, errors: &mut Vec<SyntaxError>) {
ast::DropAggregate(it) => validate_drop_aggregate(it, errors),
ast::JoinExpr(it) => validate_join_expr(it, errors),
ast::Literal(it) => validate_literal(it, errors),
ast::NonStandardParam(it) => validate_non_standard_param(it, errors),
_ => (),
}
}
Expand Down Expand Up @@ -250,3 +251,10 @@ fn validate_aggregate_params(aggregate_params: Option<ast::ParamList>, acc: &mut
}
}
}

fn validate_non_standard_param(param: ast::NonStandardParam, acc: &mut Vec<SyntaxError>) {
acc.push(SyntaxError::new(
"Invalid parameter type. Use positional params like $1 instead.",
param.syntax().text_range(),
))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- invalid param type
select :x;
select : foo;
Loading