[Bast-commits] r8478 - in branches/DBIx-Class-Schema-Loader/current: lib/DBIx/Class/Schema/Loader/DBI lib/DBIx/Class/Schema/Loader/DBI/Sybase t

caelum at dev.catalyst.perl.org caelum at dev.catalyst.perl.org
Sat Jan 30 22:24:55 GMT 2010


Author: caelum
Date: 2010-01-30 22:24:55 +0000 (Sat, 30 Jan 2010)
New Revision: 8478

Modified:
   branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm
   branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm
   branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Common.pm
   branches/DBIx-Class-Schema-Loader/current/t/15sybase_common.t
Log:
fix IDENTITY data_type for Sybase, more extra tests for Sybase

Modified: branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm	2010-01-30 21:22:15 UTC (rev 8477)
+++ branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm	2010-01-30 22:24:55 UTC (rev 8478)
@@ -2,10 +2,7 @@
 
 use strict;
 use warnings;
-use base qw/
-    DBIx::Class::Schema::Loader::DBI
-    DBIx::Class::Schema::Loader::DBI::Sybase::Common
-/;
+use base 'DBIx::Class::Schema::Loader::DBI::Sybase::Common';
 use Carp::Clan qw/^DBIx::Class/;
 use Class::C3;
 
@@ -38,18 +35,6 @@
     $self->_set_quote_char_and_name_sep;
 }
 
-# remove 'IDENTITY' from column data_type
-sub _columns_info_for {
-    my $self   = shift;
-    my $result = $self->next::method(@_);
-
-    for my $col (keys %$result) {
-        $result->{$col}->{data_type} =~ s/\s* identity \s*//ix;
-    }
-
-    return $result;
-}
-
 sub _table_pk_info {
     my ($self, $table) = @_;
     my $dbh = $self->schema->storage->dbh;

Modified: branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Common.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Common.pm	2010-01-30 21:22:15 UTC (rev 8477)
+++ branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Common.pm	2010-01-30 22:24:55 UTC (rev 8478)
@@ -2,6 +2,7 @@
 
 use strict;
 use warnings;
+use base 'DBIx::Class::Schema::Loader::DBI';
 use Carp::Clan qw/^DBIx::Class/;
 use Class::C3;
 
@@ -63,6 +64,18 @@
     return $db_schema;
 }
 
+# remove 'IDENTITY' from column data_type
+sub _columns_info_for {
+    my $self   = shift;
+    my $result = $self->next::method(@_);
+
+    for my $col (keys %$result) {
+        $result->{$col}->{data_type} =~ s/\s* identity \s*//ix;
+    }
+
+    return $result;
+}
+
 =head1 SEE ALSO
 
 L<DBIx::Class::Schema::Loader::DBI::Sybase>,

Modified: branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm	2010-01-30 21:22:15 UTC (rev 8477)
+++ branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm	2010-01-30 22:24:55 UTC (rev 8478)
@@ -2,10 +2,7 @@
 
 use strict;
 use warnings;
-use base qw/
-    DBIx::Class::Schema::Loader::DBI
-    DBIx::Class::Schema::Loader::DBI::Sybase::Common
-/;
+use base 'DBIx::Class::Schema::Loader::DBI::Sybase::Common';
 use Carp::Clan qw/^DBIx::Class/;
 use Class::C3;
 

Modified: branches/DBIx-Class-Schema-Loader/current/t/15sybase_common.t
===================================================================
--- branches/DBIx-Class-Schema-Loader/current/t/15sybase_common.t	2010-01-30 21:22:15 UTC (rev 8477)
+++ branches/DBIx-Class-Schema-Loader/current/t/15sybase_common.t	2010-01-30 22:24:55 UTC (rev 8478)
@@ -18,24 +18,62 @@
             q{
                 CREATE TABLE sybase_loader_test1 (
                     id INTEGER IDENTITY NOT NULL PRIMARY KEY,
-                    ts timestamp
+                    ts timestamp,
+                    charfield VARCHAR(10) DEFAULT 'foo',
+                    computed_dt AS getdate()
                 )
             },
         ],
         drop  => [ qw/ sybase_loader_test1 / ],
-        count => 1,
+        count => 7,
         run   => sub {
             my ($schema, $monikers, $classes) = @_;
 
             my $rs = $schema->resultset($monikers->{sybase_loader_test1});
+            my $rsrc = $rs->result_source;
 
+            is $rsrc->column_info('id')->{data_type},
+                'numeric',
+                'INTEGER IDENTITY data_type is correct';
+
+            is $rsrc->column_info('id')->{is_auto_increment},
+                1,
+                'INTEGER IDENTITY is_auto_increment => 1';
+
             {
                 local $TODO = 'timestamp introspection broken';
 
-                is $rs->result_source->column_info('ts')->{data_type},
+                is $rsrc->column_info('ts')->{data_type},
                    'timestamp',
                    'timestamps have the correct data_type';
             }
+
+            is $rsrc->column_info('charfield')->{data_type},
+                'varchar',
+                'VARCHAR has correct data_type';
+
+            {
+                local $TODO = 'constant DEFAULT introspection';
+
+                is $rsrc->column_info('charfield')->{default},
+                    'foo',
+                    'constant DEFAULT is correct';
+            }
+
+            is $rsrc->column_info('charfield')->{size},
+                10,
+                'VARCHAR(10) has correct size';
+
+            {
+                local $TODO = 'data_type for computed columns';
+
+                ok ((exists $rsrc->column_info('computed_dt')->{data_type}
+                  && (not defined $rsrc->column_info('computed_dt')->{data_type})),
+                    'data_type for computed column exists and is undef')
+#               or diag "Data type is: ",
+#                   $rsrc->column_info('computed_dt')->{data_type}
+                ;
+            }
         },
     },
 );




More information about the Bast-commits mailing list