1
0
Fork 0
mirror of https://github.com/DBD-SQLite/DBD-SQLite synced 2025-06-07 14:19:10 -04:00

fixed RT-115465: column_info doesn't parse sizes with spaces (ilmari++)

This commit is contained in:
Kenichi Ishigaki 2016-06-23 10:07:09 +09:00
parent 67c5927214
commit 25321bfda1
2 changed files with 38 additions and 1 deletions

View file

@ -855,7 +855,7 @@ END_SQL
);
my $type = $col_info->{type};
if ( $type =~ s/(\w+) ?\((\d+)(?:,(\d+))?\)/$1/ ) {
if ( $type =~ s/(\w+)\s*\(\s*(\d+)(?:\s*,\s*(\d+))?\s*\)/$1/ ) {
$col{COLUMN_SIZE} = $2;
$col{DECIMAL_DIGITS} = $3;
}

View file

@ -0,0 +1,37 @@
#!/usr/bin/perl
use strict;
BEGIN {
$| = 1;
$^W = 1;
}
use t::lib::Test;
use Test::More;
plan tests => 14;
use Test::NoWarnings;
{
my $dbh = connect_ok();
$dbh->do('create table test ( foo varchar(10), bar varchar( 15 ), baz decimal(3,3), bat decimal(4, 4))');
my %info = map {
$_->{COLUMN_NAME} => [@$_{qw/TYPE_NAME COLUMN_SIZE DECIMAL_DIGITS/}]
} @{$dbh->column_info(undef, undef, 'test', '%')->fetchall_arrayref({})};
is $info{foo}[0] => 'varchar';
is $info{foo}[1] => '10';
is $info{foo}[2] => undef;
is $info{bar}[0] => 'varchar';
is $info{bar}[1] => '15';
is $info{bar}[2] => undef;
is $info{baz}[0] => 'decimal';
is $info{baz}[1] => 3;
is $info{baz}[2] => 3;
is $info{bat}[0] => 'decimal';
is $info{bat}[1] => 4;
is $info{bat}[2] => 4;
}