day_of_month diff does not make any sense
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / SQLMaker / MSSQL.pm
index 30b0c96..b9a572c 100644 (file)
@@ -2,7 +2,6 @@ package # Hide from PAUSE
   DBIx::Class::SQLMaker::MSSQL;
 
 use base qw( DBIx::Class::SQLMaker );
-use Carp::Clan qw/^DBIx::Class|^SQL::Abstract/;
 
 #
 # MSSQL does not support ... OVER() ... RNO limits
@@ -11,4 +10,19 @@ sub _rno_default_order {
   return \ '(SELECT(1))';
 }
 
+{
+  my %part_map = (
+     month        => 'mm',
+     day_of_month => 'dd',
+     year         => 'yyyy',
+  );
+
+  my %diff_part_map = %part_map;
+  $diff_part_map{day} = delete $diff_part_map{day_of_month};
+
+  sub _datetime_sql { "DATEPART('$part_map{$_[1]}', $_[2])" }
+  sub _datetime_diff_sql { "DATEDIFF('$diff_part_map{$_[1]}', $_[2], $_[3])" }
+}
+
+
 1;