From: Dagfinn Ilmari Mannsåker Date: Fri, 8 Feb 2008 22:04:10 +0000 (+0000) Subject: Add is_auto_increment detection for Oracle X-Git-Tag: 0.04999_02~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fb328d1a79d2c6187169909b074426e24aa04cac;p=dbsrgits%2FDBIx-Class-Schema-Loader.git Add is_auto_increment detection for Oracle --- diff --git a/Changes b/Changes index 02310b2..1127e4c 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for Perl extension DBIx::Class::Schema::Loader +0.04999_02 Not yet released + - Add is_auto_increment detection for Oracle + 0.04999_01 Tue Feb 5, 2008 - Mark foreign key columns with is_foreign_key => 1 - Add support for vendor-specific extra column attributes. diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm b/lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm index c819c9d..957dd36 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm @@ -123,6 +123,31 @@ sub _columns_info_for { return $self->next::method(uc $table); } +sub _extra_column_info { + my ($self, $info) = @_; + my %extra_info; + + my ($table, $column) = @$info{qw/TABLE_NAME COLUMN_NAME/}; + + my $dbh = $self->schema->storage->dbh; + my $sth = $dbh->prepare_cached( + q{ + SELECT COUNT(*) + FROM user_triggers ut JOIN user_trigger_cols utc USING (trigger_name) + WHERE utc.table_name = ? AND utc.column_name = ? + AND column_usage LIKE '%NEW%' AND column_usage LIKE '%OUT%' + AND trigger_type = 'BEFORE EACH ROW' AND triggering_event LIKE '%INSERT%' + }, + {}, 1); + + $sth->execute($table, $column); + if ($sth->fetchrow_array) { + $extra_info{is_auto_increment} = 1; + } + + return \%extra_info; +} + =head1 SEE ALSO L, L, @@ -132,6 +157,8 @@ L TSUNODA Kazuya C +Dagfinn Ilmari MannsÃ¥ker C + =cut 1; diff --git a/t/14ora_common.t b/t/14ora_common.t index e88f8e1..2cd05b5 100644 --- a/t/14ora_common.t +++ b/t/14ora_common.t @@ -30,7 +30,6 @@ my $tester = dbixcsl_common_tests->new( dsn => $dsn, user => $user, password => $password, - no_auto_increment => 1, ); if( !$dsn || !$user ) {