File tree Expand file tree Collapse file tree
prqlc/prqlc-parser/src/parser Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -141,7 +141,7 @@ where
141141 if let ExprKind :: Ident ( name) = v. kind {
142142 Some ( name. to_string ( ) )
143143 } else {
144- emit. emit ( Rich :: custom ( span, "target must be a string literal " ) ) ;
144+ emit. emit ( Rich :: custom ( span, "target must be an identifier " ) ) ;
145145 None
146146 }
147147 } )
@@ -273,6 +273,34 @@ mod tests {
273273 crate :: parse_test!( source, module_contents( ) . then_ignore( end( ) ) )
274274 }
275275
276+ fn parse_query_def ( source : & str ) -> Result < Stmt , Vec < Error > > {
277+ crate :: parse_test!( source, query_def( ) . then_ignore( end( ) ) )
278+ }
279+
280+ #[ test]
281+ fn query_def_target_string_literal ( ) {
282+ // A `target` given as a string literal rather than an identifier
283+ // should report that it must be an identifier (the valid form is
284+ // `target:sql.duckdb`, not `target:"sql.duckdb"`).
285+ assert_debug_snapshot ! ( parse_query_def( r#"
286+ prql target:"sql.duckdb"
287+ "# ) . unwrap_err( ) , @r#"
288+ [
289+ Error {
290+ kind: Error,
291+ span: Some(
292+ 0:0-34,
293+ ),
294+ reason: Simple(
295+ "target must be an identifier",
296+ ),
297+ hints: [],
298+ code: None,
299+ },
300+ ]
301+ "# ) ;
302+ }
303+
276304 #[ test]
277305 fn test_module_contents ( ) {
278306 assert_yaml_snapshot ! ( parse_module_contents( r#"
You can’t perform that action at this time.
0 commit comments