revert 45a380dc2d68e828de4011b99f0c3739db5b0707
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / lib / dbixcsl_common_tests.pm
index 7e1489d..283805d 100644 (file)
@@ -87,7 +87,7 @@ sub run_tests {
 
     my $extra_count = $self->{extra}{count} || 0;
 
-    plan tests => @connect_info * (174 + $extra_count + ($self->{data_type_tests}{test_count} || 0));
+    plan tests => @connect_info * (176 + $extra_count + ($self->{data_type_tests}{test_count} || 0));
 
     foreach my $info_idx (0..$#connect_info) {
         my $info = $connect_info[$info_idx];
@@ -117,8 +117,17 @@ sub run_only_extra_tests {
         $self->drop_extra_tables_only;
 
         my $dbh = $self->dbconnect(1);
-        $dbh->do($_) for @{ $self->{extra}{create} || [] };
-        $dbh->do($self->{data_type_tests}{ddl}) if $self->{data_type_tests}{ddl};
+        {
+            # Silence annoying but harmless postgres "NOTICE:  CREATE TABLE..."
+            local $SIG{__WARN__} = sub {
+                my $msg = shift;
+                warn $msg unless $msg =~ m{^NOTICE:\s+CREATE TABLE};
+            };
+
+
+            $dbh->do($_) for @{ $self->{extra}{create} || [] };
+            $dbh->do($self->{data_type_tests}{ddl}) if $self->{data_type_tests}{ddl};
+        }
         $self->{_created} = 1;
 
         my $file_count = grep /CREATE (?:TABLE|VIEW)/i, @{ $self->{extra}{create} || [] };
@@ -302,7 +311,13 @@ sub test_schema {
     isa_ok( $rsobj35, "DBIx::Class::ResultSet" );
 
     my @columns_lt2 = $class2->columns;
-    is_deeply( \@columns_lt2, [ qw/id dat dat2/ ], "Column Ordering" );
+    is_deeply( \@columns_lt2, [ qw/id dat dat2 set_primary_key dbix_class_testcomponent/ ], "Column Ordering" );
+
+    is $class2->column_info('set_primary_key')->{accessor}, undef,
+        'accessor for column name that conflicts with a result base class method removed';
+
+    is $class2->column_info('dbix_class_testcomponent')->{accessor}, undef,
+        'accessor for column name that conflicts with a component class method removed';
 
     my %uniq1 = $class1->unique_constraints;
     my $uniq1_test = 0;
@@ -881,7 +896,7 @@ sub test_schema {
             # Silence annoying but harmless postgres "NOTICE:  CREATE TABLE..."
             local $SIG{__WARN__} = sub {
                 my $msg = shift;
-                print STDERR $msg unless $msg =~ m{^NOTICE:\s+CREATE TABLE};
+                warn $msg unless $msg =~ m{^NOTICE:\s+CREATE TABLE};
             };
 
             $dbh->do($_) for @statements_rescan;
@@ -1040,11 +1055,14 @@ sub create {
         q{ INSERT INTO loader_test1s (dat) VALUES('bar') }, 
         q{ INSERT INTO loader_test1s (dat) VALUES('baz') }, 
 
+        # also test method collision
         qq{ 
             CREATE TABLE loader_test2 (
                 id $self->{auto_inc_pk},
                 dat VARCHAR(32) NOT NULL,
                 dat2 VARCHAR(32) NOT NULL,
+                set_primary_key INTEGER $self->{null},
+                dbix_class_testcomponent INTEGER $self->{null},
                 UNIQUE (dat2, dat)
             ) $self->{innodb}
         },
@@ -1453,7 +1471,7 @@ sub create {
     # Silence annoying but harmless postgres "NOTICE:  CREATE TABLE..."
     local $SIG{__WARN__} = sub {
         my $msg = shift;
-        print STDERR $msg unless $msg =~ m{^NOTICE:\s+CREATE TABLE};
+        warn $msg unless $msg =~ m{^NOTICE:\s+CREATE TABLE};
     };
 
     $dbh->do($_) for (@statements);
@@ -1642,9 +1660,13 @@ sub setup_data_type_tests {
         $size =~ s/\s+//g;
         my @size = split /,/, $size;
 
-        # Firebird doesn't like very long column names
-        if ($self->{vendor} =~ /^firebird\z/i) {
-            $type_alias =~ s/default\b.*/_with_dflt/i;
+        # some DBs don't like very long column names
+        if ($self->{vendor} =~ /^firebird|sqlanywhere\z/i) {
+            my ($col_def, $default) = $type_alias =~ /^(.*)(default.*)?\z/i;
+
+            $type_alias = substr $col_def, 0, 15;
+
+            $type_alias .= '_with_dflt' if $default;
         }
 
         $type_alias =~ s/\s/_/g;
@@ -1655,7 +1677,7 @@ sub setup_data_type_tests {
         if (@size) {
             my $size_name = join '_', apply { s/\W//g } @size;
 
-            $col_name .= "_with_size_$size_name";
+            $col_name .= "_sz_$size_name";
         }
 
         $col_name .= "_$seen_col_names{$col_name}" if $seen_col_names{$col_name}++;