File tree Expand file tree Collapse file tree 3 files changed +53
-0
lines changed 
tests/data/statements/valid Expand file tree Collapse file tree 3 files changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -565,6 +565,39 @@ fn custom_handlers(node: &Node) -> TokenStream {
565565 tokens. push( TokenProperty :: from( Token :: As ) ) ; 
566566 tokens. push( TokenProperty :: from( Token :: EnumP ) ) ; 
567567 } , 
568+  "CreateCastStmt"  => quote !  { 
569+  tokens. push( TokenProperty :: from( Token :: Create ) ) ; 
570+  tokens. push( TokenProperty :: from( Token :: Cast ) ) ; 
571+  tokens. push( TokenProperty :: from( Token :: As ) ) ; 
572+  if  n. inout { 
573+  tokens. push( TokenProperty :: from( Token :: With ) ) ; 
574+  tokens. push( TokenProperty :: from( Token :: Inout ) ) ; 
575+  } 
576+  else if  n. func. is_some( )  { 
577+  tokens. push( TokenProperty :: from( Token :: With ) ) ; 
578+  tokens. push( TokenProperty :: from( Token :: Function ) ) ; 
579+  }  else { 
580+  tokens. push( TokenProperty :: from( Token :: Without ) ) ; 
581+  tokens. push( TokenProperty :: from( Token :: Function ) ) ; 
582+  } 
583+  match  n. context { 
584+  // Implicit 
585+  1  => { 
586+  tokens. push( TokenProperty :: from( Token :: As ) ) ; 
587+  tokens. push( TokenProperty :: from( Token :: ImplicitP ) ) ; 
588+  } , 
589+  // Assignment 
590+  2  => { 
591+  tokens. push( TokenProperty :: from( Token :: As ) ) ; 
592+  tokens. push( TokenProperty :: from( Token :: Assignment ) ) ; 
593+  } , 
594+  // Plpgsql 
595+  3  => { } , 
596+  // Explicit 
597+  4  => { } , 
598+  _ => panic!( "Unknown CreateCastStmt {:#?}" ,  n. context) 
599+  } 
600+  } , 
568601 _ => quote !  { } , 
569602 } 
570603} 
Original file line number Diff line number Diff line change @@ -156,4 +156,21 @@ mod tests {
156156 ] , 
157157 ) 
158158 } 
159+ 
160+  #[ test]  
161+  fn  test_create_cast ( )  { 
162+  test_get_node_properties ( 
163+  "create cast (bigint as int4) with inout as assignment;" , 
164+  SyntaxKind :: CreateCastStmt , 
165+  vec ! [ 
166+  TokenProperty :: from( SyntaxKind :: Create ) , 
167+  TokenProperty :: from( SyntaxKind :: Cast ) , 
168+  TokenProperty :: from( SyntaxKind :: As ) , 
169+  TokenProperty :: from( SyntaxKind :: With ) , 
170+  TokenProperty :: from( SyntaxKind :: Inout ) , 
171+  TokenProperty :: from( SyntaxKind :: As ) , 
172+  TokenProperty :: from( SyntaxKind :: Assignment ) , 
173+  ] , 
174+  ) 
175+  } 
159176} 
Original file line number Diff line number Diff line change 1+ CREATE CAST (bigint  AS  int4) WITH FUNCTION int4(bigint ) AS  ASSIGNMENT;
2+ CREATE CAST (bigint  AS  int4) WITHOUT FUNCTION AS  IMPLICIT;
3+ CREATE CAST (bigint  AS  int4) WITH INOUT AS  ASSIGNMENT;
                         You can’t perform that action at this time. 
           
                  
0 commit comments