Merge 'trunk' into 'DBIx-Class-current'
Matt S Trout [Sun, 12 Feb 2006 19:43:20 +0000 (19:43 +0000)]
r5957@obrien (orig r887):  matthewt | 2006-02-12 13:43:20 +0000
- add horrific fix to make Oracle's retarded limit syntax work

1  2 
lib/DBIx/Class/Storage/DBI.pm

@@@ -134,6 -134,14 +134,14 @@@ sub _quote 
    return $self->SUPER::_quote($label);
  }
  
+ sub _RowNum {
+    my $self = shift;
+    my $c;
+    $_[0] =~ s/SELECT (.*?) FROM/
+      'SELECT '.join(', ', map { $_.' AS col'.++$c } split(', ', $1)).' FROM'/e;
+    $self->SUPER::_RowNum(@_);
+ }
  # Accessor for setting limit dialect. This is useful
  # for JDBC-bridge among others where the remote SQL-dialect cannot
  # be determined by the name of the driver alone.
@@@ -264,11 -272,7 +272,11 @@@ sub _populate_dbh 
    my ($self) = @_;
    my @info = @{$self->connect_info || []};
    $self->_dbh($self->_connect(@info));
 -
 +  my $driver = $self->_dbh->{Driver}->{Name};
 +  eval "require DBIx::Class::Storage::DBI::${driver}";
 +  unless ($@) {
 +    bless $self, "DBIx::Class::Storage::DBI::${driver}";
 +  }
    # if on-connect sql statements are given execute them
    foreach my $sql_statement (@{$self->on_connect_do || []}) {
      $self->_dbh->do($sql_statement);
@@@ -429,15 -433,6 +437,15 @@@ sub columns_info_for 
      return \%result;
  }
  
 +sub last_insert_id {
 +  my ($self, $row) = @_;
 +    
 +  return $self->dbh->func('last_insert_rowid');
 +
 +}
 +
 +
 +
  sub DESTROY { shift->disconnect }
  
  1;