Add generic custom_column_info, remove oracle specific test
Robert Bohne [Wed, 17 Feb 2010 09:36:16 +0000 (10:36 +0100)]
t/14ora_common.t
t/lib/dbixcsl_common_tests.pm

index be5f692..1bbe5f1 100644 (file)
@@ -8,18 +8,8 @@ my $dsn      = $ENV{DBICTEST_ORA_DSN} || '';
 my $user     = $ENV{DBICTEST_ORA_USER} || '';
 my $password = $ENV{DBICTEST_ORA_PASS} || '';
 
-sub _custom_column_info {
-    my $info = shift;
-
-    if ( $info->{TYPE_NAME} eq 'DATE' ){
-        return { timezone => "Europe/Berlin" };
-    }
-    return;
-}
-
 my $tester = dbixcsl_common_tests->new(
     vendor      => 'Oracle',
-    custom_column_info => \&_custom_column_info,
     auto_inc_pk => 'INTEGER NOT NULL PRIMARY KEY',
     auto_inc_cb => sub {
         my ($table, $col) = @_;
@@ -42,33 +32,6 @@ my $tester = dbixcsl_common_tests->new(
     dsn         => $dsn,
     user        => $user,
     password    => $password,
-    extra => {
-        create => [qq{
-            CREATE TABLE oracle_loader_test1 (
-                id number(5) NOT NULL,
-                name varchar2(100) NOT NULL,
-                create_date date NOT NULL,
-                modification_date date,
-                PRIMARY KEY (id)
-            )
-        },],
-        drop  => [qw/ oracle_loader_test1 /],
-        count => 2,
-        run   => sub {
-            my ( $schema, $monikers, $classes ) = @_;
-            my $rs = $schema->resultset( $monikers->{oracle_loader_test1} );
-
-            is $rs->result_source->column_info('create_date')->{timezone},
-                'Europe/Berlin',
-                'create_date hast timezone';
-
-            is $rs->result_source->column_info('modification_date')->{timezone},
-                'Europe/Berlin',
-                'modification_date hast timezone';
-
-        },
-      }
-
 );
 
 if( !$dsn || !$user ) {
index 191cc0a..ebc12c1 100644 (file)
@@ -57,10 +57,21 @@ sub _monikerize {
     return undef;
 }
 
+sub _custom_column_info {
+    my $info = shift;
+
+    if ( lc( $info->{TABLE_NAME} ) eq 'loader_test11' 
+        and lc( $info->{COLUMN_NAME} ) eq 'loader_test10' 
+    ){
+        return { is_numeric => 1 }
+    }
+    return;
+}
+
 sub run_tests {
     my $self = shift;
 
-    plan tests => 145 + ($self->{extra}->{count} || 0);
+    plan tests => 146 + ($self->{extra}->{count} || 0);
 
     $self->create();
 
@@ -102,13 +113,13 @@ sub setup_schema {
         inflect_plural          => { loader_test4 => 'loader_test4zes' },
         inflect_singular        => { fkid => 'fkid_singular' },
         moniker_map             => \&_monikerize,
+        custom_column_info      => \&_custom_column_info,
         debug                   => $debug,
         use_namespaces          => 0,
         dump_directory          => $DUMP_DIR,
     );
 
     $loader_opts{db_schema} = $self->{db_schema} if $self->{db_schema};
-    $loader_opts{custom_column_info} = $self->{custom_column_info} if $self->{custom_column_info};
 
     {
        my @loader_warnings;
@@ -604,11 +615,13 @@ sub test_schema {
         my $class11   = $classes->{loader_test11};
         my $rsobj11   = $conn->resultset($moniker11);
 
-        isa_ok( $rsobj10, "DBIx::Class::ResultSet" ); 
+        isa_ok( $rsobj10, "DBIx::Class::ResultSet" );
         isa_ok( $rsobj11, "DBIx::Class::ResultSet" );
 
         ok($class10->column_info('loader_test11')->{is_foreign_key}, 'Foreign key detected');
         ok($class11->column_info('loader_test10')->{is_foreign_key}, 'Foreign key detected');
+        # Added by custom_column_info
+        ok($class11->column_info('loader_test10')->{is_numeric}, 'is_numeric detected');
 
         my $obj10 = $rsobj10->create({ subject => 'xyzzy' });