Update _order_siblings_by, use _order_by_chunks instead of own stuff
[dbsrgits/DBIx-Class-Historic.git] / lib / DBIx / Class / SQLAHacks.pm
index 13f0d97..d2cd569 100644 (file)
@@ -360,7 +360,14 @@ sub insert {
   # which is sadly understood only by MySQL. Change default behavior here,
   # until SQLA2 comes with proper dialect support
   if (! $_[0] or (ref $_[0] eq 'HASH' and !keys %{$_[0]} ) ) {
-    return "INSERT INTO ${table} DEFAULT VALUES"
+    my $sql = "INSERT INTO ${table} DEFAULT VALUES";
+
+    if (my @returning = @{ ($_[1]||{})->{returning} || [] }) {
+      $sql .= ' RETURNING (' . (join ', ' => map $self->_quote($_), @returning)
+            . ')';
+    }
+
+    return $sql;
   }
 
   $self->SUPER::insert($table, @_);