From: Matt S Trout Date: Sun, 19 Mar 2006 21:15:38 +0000 (+0000) Subject: Fix to columns_info_for for type(size) X-Git-Tag: v0.06000~58 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8fcf21b3a6e010f16ff278b9170a14a0858da388;p=dbsrgits%2FDBIx-Class.git Fix to columns_info_for for type(size) --- diff --git a/Changes b/Changes index 9ccebd1..d41331e 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for DBIx::Class +0.05999_05 + - Fixup to columns_info_for when database returns type(size) + 0.05999_04 - Fix for delete on full-table resultsets - Removed caching on count() and added _count for pager() diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 3a7d978..ded90f5 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -535,10 +535,11 @@ sub columns_info_for { $sth->execute(); while ( my $info = $sth->fetchrow_hashref() ){ my %column_info; - $column_info{data_type} = $info->{TYPE_NAME}; - $column_info{size} = $info->{COLUMN_SIZE}; - $column_info{is_nullable} = $info->{NULLABLE} ? 1 : 0; + $column_info{data_type} = $info->{TYPE_NAME}; + $column_info{size} = $info->{COLUMN_SIZE}; + $column_info{is_nullable} = $info->{NULLABLE} ? 1 : 0; $column_info{default_value} = $info->{COLUMN_DEF}; + $result{$info->{COLUMN_NAME}} = \%column_info; } }; @@ -562,6 +563,12 @@ sub columns_info_for { $column_info{data_type} = $type_name ? $type_name : $type_num; $column_info{size} = $sth->{PRECISION}->[$i]; $column_info{is_nullable} = $sth->{NULLABLE}->[$i] ? 1 : 0; + + if ($column_info{data_type} =~ m/^(.*?)\((.*?)\)$/) { + $column_info{data_type} = $1; + $column_info{size} = $2; + } + $result{$columns[$i]} = \%column_info; } diff --git a/t/lib/sqlite.sql b/t/lib/sqlite.sql index 391de14..f59aca8 100644 --- a/t/lib/sqlite.sql +++ b/t/lib/sqlite.sql @@ -1,10 +1,18 @@ -- -- Created by SQL::Translator::Producer::SQLite --- Created on Fri Feb 24 15:13:57 2006 +-- Created on Sun Mar 19 19:16:50 2006 -- BEGIN TRANSACTION; -- +-- Table: serialized +-- +CREATE TABLE serialized ( + id INTEGER PRIMARY KEY NOT NULL, + serialized text NOT NULL +); + +-- -- Table: twokeys -- CREATE TABLE twokeys ( @@ -14,6 +22,14 @@ CREATE TABLE twokeys ( ); -- +-- Table: liner_notes +-- +CREATE TABLE liner_notes ( + liner_id INTEGER PRIMARY KEY NOT NULL, + notes varchar(100) NOT NULL +); + +-- -- Table: cd_to_producer -- CREATE TABLE cd_to_producer ( @@ -23,19 +39,11 @@ CREATE TABLE cd_to_producer ( ); -- --- Table: liner_notes --- -CREATE TABLE liner_notes ( - liner_id INTEGER PRIMARY KEY NOT NULL, - notes varchar NOT NULL -); - --- -- Table: artist -- CREATE TABLE artist ( artistid INTEGER PRIMARY KEY NOT NULL, - name varchar + name varchar(100) ); -- @@ -64,8 +72,8 @@ CREATE TABLE fourkeys ( CREATE TABLE cd ( cdid INTEGER PRIMARY KEY NOT NULL, artist integer NOT NULL, - title varchar NOT NULL, - year varchar NOT NULL + title varchar(100) NOT NULL, + year varchar(100) NOT NULL ); -- @@ -93,7 +101,7 @@ CREATE TABLE track ( trackid INTEGER PRIMARY KEY NOT NULL, cd integer NOT NULL, position integer NOT NULL, - title varchar NOT NULL + title varchar(100) NOT NULL ); -- @@ -101,16 +109,7 @@ CREATE TABLE track ( -- CREATE TABLE producer ( producerid INTEGER PRIMARY KEY NOT NULL, - name varchar NOT NULL -); - --- --- Table: treelike --- -CREATE TABLE treelike ( - id INTEGER PRIMARY KEY NOT NULL, - parent integer NOT NULL, - name varchar NOT NULL + name varchar(100) NOT NULL ); -- @@ -119,7 +118,7 @@ CREATE TABLE treelike ( CREATE TABLE tags ( tagid INTEGER PRIMARY KEY NOT NULL, cd integer NOT NULL, - tag varchar NOT NULL + tag varchar(100) NOT NULL ); -- @@ -127,15 +126,16 @@ CREATE TABLE tags ( -- CREATE TABLE self_ref ( id INTEGER PRIMARY KEY NOT NULL, - name varchar NOT NULL + name varchar(100) NOT NULL ); -- --- Table: serialized +-- Table: treelike -- -CREATE TABLE serialized ( - id INTEGER PRIMARY KEY NOT NULL, - serialized text NOT NULL +CREATE TABLE treelike ( + id INTEGER PRIMARY KEY NOT NULL, + parent integer NOT NULL, + name varchar(100) NOT NULL ); COMMIT; diff --git a/t/run/04db.tl b/t/run/04db.tl index 424948c..57aa819 100644 --- a/t/run/04db.tl +++ b/t/run/04db.tl @@ -38,7 +38,7 @@ my $test_type_info = { 'name' => { 'data_type' => 'varchar', 'is_nullable' => 0, - 'size' => undef, + 'size' => 100, } }; is_deeply($type_info, $test_type_info, 'columns_info_for - column data types');