set correct size for n(var)?char columns for ASE
Rafael Kitover [Sat, 7 Apr 2012 18:22:29 +0000 (14:22 -0400)]
Based on @@ncharsize.

Changes
lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm
t/10_06sybase_common.t

diff --git a/Changes b/Changes
index 2d0cff6..38c7c32 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
 Revision history for Perl extension DBIx::Class::Schema::Loader
 
+        - set correct size for nchar/nvarchar columns for Sybase ASE,
+          depending on @@ncharsize
+
 0.07021  2012-04-04 23:47:34
         - use ::Schema::connect instead of ::Schema::connection in
           make_schema_at (RT#74175)
index 88def8c..fce5f1a 100644 (file)
@@ -399,6 +399,7 @@ EOF
         if ($sth->fetchrow_array) {
             $res->{is_auto_increment} = 1;
         }
+        $sth->finish;
 
         if ($data_type && $data_type =~ /^timestamp\z/i) {
             $res->{inflate_datetime} = 0;
@@ -449,6 +450,11 @@ EOF
                 if ($data_type =~ /^(?:unichar|univarchar)\z/i) {
                     $res->{size} /= 2;
                 }
+                elsif ($data_type =~ /^n(?:var)?char\z/i) {
+                    my ($nchar_size) = $self->dbh->selectrow_array('SELECT @@ncharsize');
+
+                    $res->{size} /= $nchar_size;
+                }
             }
         }
 
index afce0d0..fe110f6 100644 (file)
@@ -261,6 +261,8 @@ EOF
                                 [ $dsn, $user, $password ],
                             );
 
+                            SybaseMultiSchema->storage->disconnect;
+
                             diag join "\n", @warns if @warns;
 
                             is @warns, 0;