File tree 2 files changed +17
-1
lines changed
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,6 @@ impl Dialect for SQLiteDialect {
41
41
ch. is_ascii_lowercase ( )
42
42
|| ch. is_ascii_uppercase ( )
43
43
|| ch == '_'
44
- || ch == '$'
45
44
|| ( '\u{007f}' ..='\u{ffff}' ) . contains ( & ch)
46
45
}
47
46
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ mod test_utils;
20
20
use test_utils:: * ;
21
21
22
22
use sqlparser:: ast:: SelectItem :: UnnamedExpr ;
23
+ use sqlparser:: ast:: Value :: Placeholder ;
23
24
use sqlparser:: ast:: * ;
24
25
use sqlparser:: dialect:: { GenericDialect , SQLiteDialect } ;
25
26
use sqlparser:: parser:: { ParserError , ParserOptions } ;
@@ -470,6 +471,22 @@ fn parse_start_transaction_with_modifier() {
470
471
) ;
471
472
}
472
473
474
+ #[ test]
475
+ fn test_dollar_identifier_as_placeholder ( ) {
476
+ // This relates to the discussion in issue #291. The `$id` should be treated as a placeholder,
477
+ // not as an identifier in SQLite dialect.
478
+ //
479
+ // Reference: https://www.sqlite.org/lang_expr.html#varparam
480
+ match sqlite ( ) . verified_expr ( "id = $id" ) {
481
+ Expr :: BinaryOp { op, left, right } => {
482
+ assert_eq ! ( op, BinaryOperator :: Eq ) ;
483
+ assert_eq ! ( left, Box :: new( Expr :: Identifier ( Ident :: new( "id" ) ) ) ) ;
484
+ assert_eq ! ( right, Box :: new( Expr :: Value ( Placeholder ( "$id" . to_string( ) ) ) ) ) ;
485
+ }
486
+ _ => unreachable ! ( ) ,
487
+ }
488
+ }
489
+
473
490
fn sqlite ( ) -> TestedDialects {
474
491
TestedDialects {
475
492
dialects : vec ! [ Box :: new( SQLiteDialect { } ) ] ,
You can’t perform that action at this time.
0 commit comments