add CAST() to ExtraClauses
[scpubgit/Q-Branch.git] / 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;
 }