File tree Expand file tree Collapse file tree 2 files changed +26
-16
lines changed
Expand file tree Collapse file tree 2 files changed +26
-16
lines changed Original file line number Diff line number Diff line change @@ -1786,6 +1786,20 @@ mod tests {
17861786 expected
17871787 ) ;
17881788 }
1789+ #[ test]
1790+ fn it_formats_raw_sql_and_conditional_queries ( ) {
1791+ let input = "SELECT {foo: &[T]}, {b.c()}, {d.e};" ;
1792+ let options = FormatOptions :: default ( ) ;
1793+ let expected = indoc ! (
1794+ "
1795+ SELECT
1796+ {foo: &[T]},
1797+ {b.c()},
1798+ {d.e};"
1799+ ) ;
1800+
1801+ assert_eq ! ( format( input, & QueryParams :: None , & options) , expected) ;
1802+ }
17891803
17901804 #[ test]
17911805 fn it_formats_query_with_go_batch_separator ( ) {
Original file line number Diff line number Diff line change @@ -384,22 +384,18 @@ fn get_ident_named_placeholder_token<'i>(input: &mut &'i str) -> Result<Token<'i
384384}
385385
386386fn get_braced_named_placeholder_token < ' i > ( input : & mut & ' i str ) -> Result < Token < ' i > > {
387- delimited (
388- '{' ,
389- take_while ( 1 .., |c : char | c. is_alphanumeric ( ) || c == '_' ) ,
390- '}' ,
391- )
392- . with_taken ( )
393- . parse_next ( input)
394- . map ( |( index, token) | {
395- let index = Cow :: Borrowed ( index) ;
396- Token {
397- kind : TokenKind :: Placeholder ,
398- value : token,
399- key : Some ( PlaceholderKind :: Named ( index) ) ,
400- alias : token,
401- }
402- } )
387+ delimited ( '{' , take_until ( 1 .., '}' ) , '}' )
388+ . with_taken ( )
389+ . parse_next ( input)
390+ . map ( |( index, token) | {
391+ let index = Cow :: Borrowed ( index) ;
392+ Token {
393+ kind : TokenKind :: Placeholder ,
394+ value : token,
395+ key : Some ( PlaceholderKind :: Named ( index) ) ,
396+ alias : token,
397+ }
398+ } )
403399}
404400
405401fn get_string_named_placeholder_token < ' i > (
You can’t perform that action at this time.
0 commit comments