[Bast-commits] r8415 - in DBIx-Class/0.08/branches/informix/lib/DBIx/Class: . Storage/DBI

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Fri Jan 22 10:59:26 GMT 2010


Author: ribasushi
Date: 2010-01-22 10:59:25 +0000 (Fri, 22 Jan 2010)
New Revision: 8415

Added:
   DBIx-Class/0.08/branches/informix/lib/DBIx/Class/Storage/DBI/Informix.pm
Modified:
   DBIx-Class/0.08/branches/informix/lib/DBIx/Class/SQLAHacks.pm
Log:
Initial informix support

Modified: DBIx-Class/0.08/branches/informix/lib/DBIx/Class/SQLAHacks.pm
===================================================================
--- DBIx-Class/0.08/branches/informix/lib/DBIx/Class/SQLAHacks.pm	2010-01-22 10:35:35 UTC (rev 8414)
+++ DBIx-Class/0.08/branches/informix/lib/DBIx/Class/SQLAHacks.pm	2010-01-22 10:59:25 UTC (rev 8415)
@@ -84,6 +84,24 @@
   return undef;
 }
 
+# Informix specific limit, almost like LIMIT/OFFSET
+sub _SkipFirst {
+  my ($self, $sql, $order, $rows, $offset) = @_;
+
+  $sql =~ s/^ \s* SELECT \s+ //ix
+    or croak "Unrecognizable SELECT: $sql";
+
+  return sprintf ('SELECT %s%s%s%s',
+    $offset
+      ? sprintf ('SKIP %d ', $offset)
+      : ''
+    ,
+    sprintf ('FIRST %d ', $rows),
+    $sql,
+    $self->_order_by ($order),
+  );
+}
+
 # Crappy Top based Limit/Offset support. Legacy from MSSQL.
 sub _Top {
   my ( $self, $sql, $order, $rows, $offset ) = @_;

Added: DBIx-Class/0.08/branches/informix/lib/DBIx/Class/Storage/DBI/Informix.pm
===================================================================
--- DBIx-Class/0.08/branches/informix/lib/DBIx/Class/Storage/DBI/Informix.pm	                        (rev 0)
+++ DBIx-Class/0.08/branches/informix/lib/DBIx/Class/Storage/DBI/Informix.pm	2010-01-22 10:59:25 UTC (rev 8415)
@@ -0,0 +1,57 @@
+package DBIx::Class::Storage::DBI::Informix;
+use strict;
+use warnings;
+
+use base qw/DBIx::Class::Storage::DBI/;
+
+use mro 'c3';
+
+__PACKAGE__->mk_group_accessors('simple' => '__last_insert_id');
+
+sub _execute {
+  my $self = shift;
+  my ($op) = @_;
+  my ($rv, $sth, @rest) = $self->next::method(@_);
+  if ($op eq 'insert') {
+    $self->__last_insert_id($sth->{ix_sqlerrd}[1]);
+  }
+  return (wantarray ? ($rv, $sth, @rest) : $rv);
+}
+
+sub last_insert_id {
+  shift->__last_insert_id;
+}
+
+sub _sql_maker_opts {
+  my ( $self, $opts ) = @_;
+
+  if ( $opts ) {
+    $self->{_sql_maker_opts} = { %$opts };
+  }
+
+  return { limit_dialect => 'SkipFirst', %{$self->{_sql_maker_opts}||{}} };
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+DBIx::Class::Storage::DBI::Informix - Base Storage Class for INFORMIX Support
+
+=head1 SYNOPSIS
+
+=head1 DESCRIPTION
+
+This class implements storage-specific support for Informix
+
+=head1 AUTHORS
+
+See L<DBIx::Class/CONTRIBUTORS>
+
+=head1 LICENSE
+
+You may distribute this code under the same terms as Perl itself.
+
+=cut




More information about the Bast-commits mailing list