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:
parent
67c5927214
commit
25321bfda1
2 changed files with 38 additions and 1 deletions
|
@ -855,7 +855,7 @@ END_SQL
|
||||||
);
|
);
|
||||||
|
|
||||||
my $type = $col_info->{type};
|
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{COLUMN_SIZE} = $2;
|
||||||
$col{DECIMAL_DIGITS} = $3;
|
$col{DECIMAL_DIGITS} = $3;
|
||||||
}
|
}
|
||||||
|
|
37
t/rt_115465_column_info_with_spaces.t
Normal file
37
t/rt_115465_column_info_with_spaces.t
Normal 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;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue