add CAST() to ExtraClauses
Matt S Trout [Fri, 17 May 2019 02:21:59 +0000 (02:21 +0000)]
lib/SQL/Abstract/ExtraClauses.pm

index 2dafda1..a632896 100644 (file)
@@ -176,6 +176,13 @@ sub register_defaults {
       for qw(with with_recursive);
     $self->clause_renderer("${stmt}.with", $with_renderer);
   }
+  $self->expander(cast => sub {
+    my ($cast, $to) = @{$_[2]};
+    +{ -func => [ cast => { -as => [
+      $self->expand_expr($cast),
+      $self->expand_expr($to, -ident),
+    ] } ] };
+  });
 
   return $self;
 }