set correct size for n(var)?char columns for ASE
[dbsrgits/DBIx-Class-Schema-Loader.git] / lib / DBIx / Class / Schema / Loader / DBI / Sybase.pm
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;
+                }
             }
         }