Rename SQLAHacks to SQLMaker, shuffle around files, add extensive
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / Oracle / Generic.pm
index ab2678e..786a000 100644 (file)
@@ -7,6 +7,8 @@ use Context::Preserve 'preserve_context';
 use Try::Tiny;
 use namespace::clean;
 
+__PACKAGE__->sql_limit_dialect ('RowNum');
+
 =head1 NAME
 
 DBIx::Class::Storage::DBI::Oracle::Generic - Oracle Support for DBIx::Class
@@ -77,7 +79,7 @@ versions before 9.
 use base qw/DBIx::Class::Storage::DBI/;
 use mro 'c3';
 
-__PACKAGE__->sql_maker_class('DBIx::Class::SQLAHacks::Oracle');
+__PACKAGE__->sql_maker_class('DBIx::Class::SQLMaker::Oracle');
 
 sub deployment_statements {
   my $self = shift;;
@@ -134,7 +136,7 @@ sub _dbh_get_autoinc_seq {
   my ( $schema, $table ) = $source_name =~ /(\w+)\.(\w+)/;
   my ($sql, @bind) = $sql_maker->select (
     'ALL_TRIGGERS',
-    ['trigger_body'],
+    ['trigger_body', 'table_owner'],
     {
       $schema ? (owner => $schema) : (),
       table_name => $table || $source_name,
@@ -145,10 +147,18 @@ sub _dbh_get_autoinc_seq {
   my $sth = $dbh->prepare($sql);
   $sth->execute (@bind);
 
-  while (my ($insert_trigger) = $sth->fetchrow_array) {
-    return $1 if $insert_trigger =~ m!("?\w+"?)\.nextval!i; # col name goes here???
+  while (my ($insert_trigger, $schema) = $sth->fetchrow_array) {
+    my ($seq_name) = $insert_trigger =~ m!("?[.\w"]+"?)\.nextval!i;
+
+    next unless $seq_name;
+
+    if ($seq_name !~ /\./) {
+      $seq_name = join '.' => $schema, $seq_name;
+    }
+
+    return $seq_name;
   }
-  $self->throw_exception("Unable to find a sequence INSERT trigger on table '$source_name'.");
+  $self->throw_exception("Unable to find a sequence %INSERT% trigger on table '$source_name'.");
 }
 
 sub _sequence_fetch {