This is an automated email from the git hooks/post-receive script.

carnil pushed a commit to branch master
in repository libdbd-sqlite3-perl.

commit 25321bfda15e0f0996fa9b202d5243918f620786
Author: Kenichi Ishigaki <ishig...@cpan.org>
Date:   Thu Jun 23 10:07:09 2016 +0900

    fixed RT-115465: column_info doesn't parse sizes with spaces (ilmari++)
---
 lib/DBD/SQLite.pm                     |  2 +-
 t/rt_115465_column_info_with_spaces.t | 37 +++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/lib/DBD/SQLite.pm b/lib/DBD/SQLite.pm
index a28a57c..609ccce 100644
--- a/lib/DBD/SQLite.pm
+++ b/lib/DBD/SQLite.pm
@@ -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;
             }
diff --git a/t/rt_115465_column_info_with_spaces.t 
b/t/rt_115465_column_info_with_spaces.t
new file mode 100644
index 0000000..3d6c0c6
--- /dev/null
+++ b/t/rt_115465_column_info_with_spaces.t
@@ -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;
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-perl/packages/libdbd-sqlite3-perl.git

_______________________________________________
Pkg-perl-cvs-commits mailing list
Pkg-perl-cvs-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits

Reply via email to