From: Peter Rabbitson Date: Thu, 9 Oct 2008 11:47:39 +0000 (+0000) Subject: Add new column with a default to Artist, adjust tests as necessary (no functional... X-Git-Tag: v0.08240~326 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=39da2a2bbc09419f5c6ed79eaf9f463982d4ad83;hp=ebf846e8113e65d2c3b2cddb7667b15a15a79813;p=dbsrgits%2FDBIx-Class.git Add new column with a default to Artist, adjust tests as necessary (no functional changes) --- diff --git a/t/64db.t b/t/64db.t index d9c03aa..3a761e4 100644 --- a/t/64db.t +++ b/t/64db.t @@ -39,8 +39,8 @@ my $type_info = $schema->storage->columns_info_for('artist'); # I know this is gross but SQLite reports the size differently from release # to release. At least this way the test still passes. -delete $type_info->{artistid}{size}; -delete $type_info->{name}{size}; +delete $type_info->{$_}{size} for keys %$type_info; + my $test_type_info = { 'artistid' => { @@ -51,6 +51,10 @@ my $test_type_info = { 'data_type' => 'varchar', 'is_nullable' => 0, }, + 'rank' => { + 'data_type' => 'integer', + 'is_nullable' => 0, + }, }; is_deeply($type_info, $test_type_info, 'columns_info_for - column data types'); diff --git a/t/71mysql.t b/t/71mysql.t index 83f2a84..eff456d 100644 --- a/t/71mysql.t +++ b/t/71mysql.t @@ -21,7 +21,7 @@ my $dbh = $schema->storage->dbh; $dbh->do("DROP TABLE IF EXISTS artist;"); -$dbh->do("CREATE TABLE artist (artistid INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), charfield CHAR(10));"); +$dbh->do("CREATE TABLE artist (artistid INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), rank INTEGER NOT NULL DEFAULT '13', charfield CHAR(10));"); #'dbi:mysql:host=localhost;database=dbic_test', 'dbic_test', ''); @@ -60,6 +60,12 @@ my $test_type_info = { 'size' => 255, 'default_value' => undef, }, + 'rank' => { + 'data_type' => 'INT', + 'is_nullable' => 0, + 'size' => 11, + 'default_value' => 13, + }, 'charfield' => { 'data_type' => 'CHAR', 'is_nullable' => 1, diff --git a/t/746mssql.t b/t/746mssql.t index 9d46eea..aebdbf4 100644 --- a/t/746mssql.t +++ b/t/746mssql.t @@ -25,6 +25,7 @@ eval { $dbh->do("DROP TABLE artist") }; CREATE TABLE artist ( artistid INT IDENTITY NOT NULL, name VARCHAR(255), + rank INT NOT NULL DEFAULT '13', charfield CHAR(10) NULL, primary key(artistid) ) diff --git a/t/74mssql.t b/t/74mssql.t index 6ad30d6..44709cb 100644 --- a/t/74mssql.t +++ b/t/74mssql.t @@ -29,7 +29,7 @@ $dbh->do("IF OBJECT_ID('artist', 'U') IS NOT NULL $dbh->do("IF OBJECT_ID('cd', 'U') IS NOT NULL DROP TABLE cd"); -$dbh->do("CREATE TABLE artist (artistid INT IDENTITY PRIMARY KEY, name VARCHAR(255));"); +$dbh->do("CREATE TABLE artist (artistid INT IDENTITY PRIMARY KEY, name VARCHAR(255), rank INT DEFAULT '13');"); $dbh->do("CREATE TABLE cd (cdid INT IDENTITY PRIMARY KEY, artist INT, title VARCHAR(100), year VARCHAR(100), genreid INT NULL);"); # Just to test compat shim, Auto is in Core $schema->class('Artist')->load_components('PK::Auto::MSSQL'); diff --git a/t/93nobindvars.t b/t/93nobindvars.t index c955a06..eddd72f 100644 --- a/t/93nobindvars.t +++ b/t/93nobindvars.t @@ -40,7 +40,7 @@ my $dbh = $schema->storage->dbh; $dbh->do("DROP TABLE IF EXISTS artist;"); -$dbh->do("CREATE TABLE artist (artistid INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), charfield CHAR(10));"); +$dbh->do("CREATE TABLE artist (artistid INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), rank INTEGER NOT NULL DEFAULT '13', charfield CHAR(10));"); $schema->class('Artist')->load_components('PK::Auto'); diff --git a/t/98savepoints.t b/t/98savepoints.t index 28b00cf..a7c5344 100644 --- a/t/98savepoints.t +++ b/t/98savepoints.t @@ -11,11 +11,11 @@ my ($create_sql, $dsn, $user, $pass); if (exists $ENV{DBICTEST_PG_DSN}) { ($dsn, $user, $pass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/}; - $create_sql = "CREATE TABLE artist (artistid serial PRIMARY KEY, name VARCHAR(100), charfield CHAR(10))"; + $create_sql = "CREATE TABLE artist (artistid serial PRIMARY KEY, name VARCHAR(100), rank INTEGER NOT NULL DEFAULT '13', charfield CHAR(10))"; } elsif (exists $ENV{DBICTEST_MYSQL_DSN}) { ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MYSQL_${_}" } qw/DSN USER PASS/}; - $create_sql = "CREATE TABLE artist (artistid INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), charfield CHAR(10)) ENGINE=InnoDB"; + $create_sql = "CREATE TABLE artist (artistid INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), rank INTEGER NOT NULL DEFAULT '13', charfield CHAR(10)) ENGINE=InnoDB"; } else { plan skip_all => 'Set DBICTEST_(PG|MYSQL)_DSN _USER and _PASS if you want to run savepoint tests'; } diff --git a/t/bindtype_columns.t b/t/bindtype_columns.t index 8edf7af..7cc712c 100644 --- a/t/bindtype_columns.t +++ b/t/bindtype_columns.t @@ -24,7 +24,8 @@ my $dbh = $schema->storage->dbh; ( artistid serial NOT NULL PRIMARY KEY, media bytea NOT NULL, - name varchar NULL + name varchar NULL, + rank integer NOT NULL DEFAULT '13' ); ],{ RaiseError => 1, PrintError => 1 }); } diff --git a/t/lib/DBICTest/Schema/Artist.pm b/t/lib/DBICTest/Schema/Artist.pm index ae92606..a542576 100644 --- a/t/lib/DBICTest/Schema/Artist.pm +++ b/t/lib/DBICTest/Schema/Artist.pm @@ -19,6 +19,10 @@ __PACKAGE__->add_columns( size => 100, is_nullable => 1, }, + rank => { + data_type => 'integer', + default_value => 13, + }, ); __PACKAGE__->set_primary_key('artistid'); diff --git a/t/lib/sqlite.sql b/t/lib/sqlite.sql index e09d0ea..15967b3 100644 --- a/t/lib/sqlite.sql +++ b/t/lib/sqlite.sql @@ -1,6 +1,6 @@ -- -- Created by SQL::Translator::Producer::SQLite --- Created on Thu Oct 9 13:12:46 2008 +-- Created on Thu Oct 9 13:44:56 2008 -- BEGIN TRANSACTION; @@ -10,7 +10,8 @@ BEGIN TRANSACTION; -- CREATE TABLE artist ( artistid INTEGER PRIMARY KEY NOT NULL, - name varchar(100) + name varchar(100), + rank integer NOT NULL DEFAULT '13' );