File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
crates/pgt_workspace/src/workspace/server Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -404,3 +404,27 @@ impl<'a> StatementFilter<'a> for IdFilter {
404404 * id == self . id
405405 }
406406}
407+
408+ #[ cfg( test) ]
409+ mod tests {
410+ use super :: * ;
411+
412+ use pgt_fs:: PgTPath ;
413+
414+ #[ test]
415+ fn sql_function_body ( ) {
416+ let input = "CREATE FUNCTION add(integer, integer) RETURNS integer
417+ AS 'select $1 + $2;'
418+ LANGUAGE SQL
419+ IMMUTABLE
420+ RETURNS NULL ON NULL INPUT;" ;
421+
422+ let path = PgTPath :: new ( "test.sql" ) ;
423+
424+ let d = ParsedDocument :: new ( path, input. to_string ( ) , 0 ) ;
425+
426+ let stmts = d. iter ( DefaultMapper ) . collect :: < Vec < _ > > ( ) ;
427+
428+ assert_eq ! ( stmts. len( ) , 2 ) ;
429+ }
430+ }
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ use pgt_text_size::TextRange;
55
66use super :: statement_identifier:: StatementId ;
77
8+ #[ derive( Debug , Clone ) ]
89pub struct SQLFunctionBody {
910 pub range : TextRange ,
1011 pub body : String ,
@@ -97,6 +98,16 @@ fn find_option_value(
9798 . find_map ( |arg| {
9899 if let pgt_query_ext:: NodeEnum :: String ( s) = arg {
99100 Some ( s. sval . clone ( ) )
101+ } else if let pgt_query_ext:: NodeEnum :: List ( l) = arg {
102+ l. items . iter ( ) . find_map ( |item_wrapper| {
103+ if let Some ( pgt_query_ext:: NodeEnum :: String ( s) ) =
104+ item_wrapper. node . as_ref ( )
105+ {
106+ Some ( s. sval . clone ( ) )
107+ } else {
108+ None
109+ }
110+ } )
100111 } else {
101112 None
102113 }
You can’t perform that action at this time.
0 commit comments