Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2f7dfda

Browse files
authored
parser: syntax error for non standard placeholders (#561)
1 parent6d8fb36 commit2f7dfda

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
source:crates/squawk_syntax/src/test.rs
3+
input_file:crates/squawk_syntax/test_data/validation/non_standard_param.sql
4+
---
5+
SOURCE_FILE@0..47
6+
COMMENT@0..21"-- invalid param type"
7+
WHITESPACE@21..22"\n"
8+
SELECT@22..31
9+
SELECT_CLAUSE@22..31
10+
SELECT_KW@22..28"select"
11+
WHITESPACE@28..29""
12+
TARGET_LIST@29..31
13+
TARGET@29..31
14+
NON_STANDARD_PARAM@29..31
15+
COLON@29..30":"
16+
NAME_REF@30..31
17+
IDENT@30..31"x"
18+
SEMICOLON@31..32";"
19+
WHITESPACE@32..33"\n"
20+
SELECT@33..45
21+
SELECT_CLAUSE@33..45
22+
SELECT_KW@33..39"select"
23+
WHITESPACE@39..40""
24+
TARGET_LIST@40..45
25+
TARGET@40..45
26+
NON_STANDARD_PARAM@40..45
27+
COLON@40..41":"
28+
WHITESPACE@41..42""
29+
NAME_REF@42..45
30+
IDENT@42..45"foo"
31+
SEMICOLON@45..46";"
32+
WHITESPACE@46..47"\n"
33+
34+
ERROR@29:31"Invalid parameter type. Use positional params like $1 instead."
35+
ERROR@40:45"Invalid parameter type. Use positional params like $1 instead."

‎crates/squawk_syntax/src/validation.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub(crate) fn validate(root: &SyntaxNode, errors: &mut Vec<SyntaxError>) {
2020
ast::DropAggregate(it) => validate_drop_aggregate(it, errors),
2121
ast::JoinExpr(it) => validate_join_expr(it, errors),
2222
ast::Literal(it) => validate_literal(it, errors),
23+
ast::NonStandardParam(it) => validate_non_standard_param(it, errors),
2324
_ =>(),
2425
}
2526
}
@@ -250,3 +251,10 @@ fn validate_aggregate_params(aggregate_params: Option<ast::ParamList>, acc: &mut
250251
}
251252
}
252253
}
254+
255+
fnvalidate_non_standard_param(param: ast::NonStandardParam,acc:&mutVec<SyntaxError>){
256+
acc.push(SyntaxError::new(
257+
"Invalid parameter type. Use positional params like $1 instead.",
258+
param.syntax().text_range(),
259+
))
260+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- invalid param type
2+
select :x;
3+
select : foo;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp