[Dbix-class] Overriding limit_dialect

Jesper Krogh jesper at krogh.cc
Wed Jan 25 15:38:49 CET 2006


hi.

I've tried to use DBIx::Class against a DBD::JDBC database (MS SQL Server)
and it generally works fine, except that the call to SQL::Abstract::Limit
cannot deduce the limit dialect on the remote server.

This patch allows to explicit specify the limit dialect in the main
connection:

__PACKAGE__->connection("dbi:JDBC:hostname=$hostname;port=$port;url=$url",$user,$password,{"limit_dialect"
=> "postgresql"});


Index: lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- lib/DBIx/Class/Storage/DBI.pm       (revision 703)
+++ lib/DBIx/Class/Storage/DBI.pm       (working copy)
@@ -180,7 +180,11 @@
 sub sql_maker {
   my ($self) = @_;
   unless ($self->_sql_maker) {
-    $self->_sql_maker(new DBIC::SQL::Abstract( limit_dialect =>
$self->dbh ));
+    my $dialect = $self->dbh;
+    if(defined $self->{connect_attrs}->{limit_dialect}){
+        $dialect = $self->{connect_attrs}->{limit_dialect};
+    }
+    $self->_sql_maker(new DBIC::SQL::Abstract( limit_dialect => $dialect ));
   }
   return $self->_sql_maker;
 }
@@ -198,6 +202,7 @@

 sub _connect {
   my ($self, @info) = @_;
+  $self->{connect_attrs} = $info[3] if $info[3];
   return DBI->connect(@info);
 }

Jesper
-- 
Jesper Krogh




More information about the Dbix-class mailing list