X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSQLAHacks.pm;h=7c5d783b7eb0d9a9ebbd85e40941bd268df68924;hb=ef8d02eb7856f32ef1d738aba4923a167c6ed2df;hp=4c783c1bba1a229e4c536f0ff8cdc8defb5fbd44;hpb=193590c261bf21b2ec81667295b78703f5d7bc82;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/SQLAHacks.pm b/lib/DBIx/Class/SQLAHacks.pm index 4c783c1..7c5d783 100644 --- a/lib/DBIx/Class/SQLAHacks.pm +++ b/lib/DBIx/Class/SQLAHacks.pm @@ -102,6 +102,24 @@ sub _SkipFirst { ); } +# Firebird specific limit, reverse of _SkipFirst for Informix +sub _FirstSkip { + my ($self, $sql, $order, $rows, $offset) = @_; + + $sql =~ s/^ \s* SELECT \s+ //ix + or croak "Unrecognizable SELECT: $sql"; + + return sprintf ('SELECT %s%s%s%s', + sprintf ('FIRST %d ', $rows), + $offset + ? sprintf ('SKIP %d ', $offset) + : '' + , + $sql, + $self->_order_by ($order), + ); +} + # Crappy Top based Limit/Offset support. Legacy from MSSQL. sub _Top { my ( $self, $sql, $order, $rows, $offset ) = @_; @@ -342,7 +360,13 @@ 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 $ret = ($_[1]||{})->{returning} ) { + $sql .= $self->_insert_returning ($ret); + } + + return $sql; } $self->SUPER::insert($table, @_); @@ -407,7 +431,7 @@ sub _recurse_fields { $self->_sqlcase($func), $self->_recurse_fields($args), $as - ? sprintf (' %s %s', $self->_sqlcase('as'), $as) + ? sprintf (' %s %s', $self->_sqlcase('as'), $self->_quote ($as) ) : '' );