[Bast-commits] r9360 - in
DBIx-Class-DynamicDefault/1.000/branches/post-03_wreis_add_column_bug:
. t t/lib t/lib/TestSchema
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Wed May 12 14:19:30 GMT 2010
Author: ribasushi
Date: 2010-05-12 15:19:30 +0100 (Wed, 12 May 2010)
New Revision: 9360
Added:
DBIx-Class-DynamicDefault/1.000/branches/post-03_wreis_add_column_bug/t/lib/DBICTest.pm
DBIx-Class-DynamicDefault/1.000/branches/post-03_wreis_add_column_bug/t/lib/TestSchema/Extended.pm
DBIx-Class-DynamicDefault/1.000/branches/post-03_wreis_add_column_bug/t/lib/sqlite.sql
Modified:
DBIx-Class-DynamicDefault/1.000/branches/post-03_wreis_add_column_bug/Makefile.PL
DBIx-Class-DynamicDefault/1.000/branches/post-03_wreis_add_column_bug/t/basic.t
Log:
Changes from former trunk
Modified: DBIx-Class-DynamicDefault/1.000/branches/post-03_wreis_add_column_bug/Makefile.PL
===================================================================
--- DBIx-Class-DynamicDefault/1.000/branches/post-03_wreis_add_column_bug/Makefile.PL 2010-05-12 14:17:14 UTC (rev 9359)
+++ DBIx-Class-DynamicDefault/1.000/branches/post-03_wreis_add_column_bug/Makefile.PL 2010-05-12 14:19:30 UTC (rev 9360)
@@ -8,8 +8,6 @@
requires 'DBIx::Class' => '0.08009';
requires 'parent';
-build_requires 'DBICx::TestDatabase';
-
makemaker_args(depend => { dist => 'README' });
auto_provides;
extra_tests;
Modified: DBIx-Class-DynamicDefault/1.000/branches/post-03_wreis_add_column_bug/t/basic.t
===================================================================
--- DBIx-Class-DynamicDefault/1.000/branches/post-03_wreis_add_column_bug/t/basic.t 2010-05-12 14:17:14 UTC (rev 9359)
+++ DBIx-Class-DynamicDefault/1.000/branches/post-03_wreis_add_column_bug/t/basic.t 2010-05-12 14:19:30 UTC (rev 9360)
@@ -7,10 +7,12 @@
use FindBin;
use lib "$FindBin::Bin/lib";
+use DBICTest;
-my $schema = DBICx::TestDatabase->new('TestSchema');
+my $schema = DBICTest->init_schema;.
my $rs = $schema->resultset('Table');
my $rs2 = $schema->resultset('Affe');
+my $rs3 = $schema->resultset('Extended');
my $row = $rs->create({ fred => 'affe' });
@@ -45,3 +47,9 @@
is($row->moo, 1, 'default on update without changes and always_update');
is($row->kooh, 'zomtec', 'on update default without always_update if another col is changed due to always_update');
+
+
+$row = $rs3->create({ fred => 'affe2' });
+ok($row->quux, 'default on create with methodname for quux');
+ok($row->extra_field, 'default on create with methodname for extra_field');
+
Added: DBIx-Class-DynamicDefault/1.000/branches/post-03_wreis_add_column_bug/t/lib/DBICTest.pm
===================================================================
--- DBIx-Class-DynamicDefault/1.000/branches/post-03_wreis_add_column_bug/t/lib/DBICTest.pm (rev 0)
+++ DBIx-Class-DynamicDefault/1.000/branches/post-03_wreis_add_column_bug/t/lib/DBICTest.pm 2010-05-12 14:19:30 UTC (rev 9360)
@@ -0,0 +1,71 @@
+package # hide from PAUSE
+ DBICTest;
+
+use strict;
+use warnings;
+use TestSchema;
+
+=head1 NAME
+
+DBICTest - Minimal version of DBICTest from the DBIx::Class dist
+
+=head1 SYNOPSIS
+
+ use lib qw(t/lib);
+ use DBICTest;
+ use Test::More;
+
+ my $schema = DBICTest->init_schema();
+
+=head1 DESCRIPTION
+
+This module provides the basic utilities to write tests against
+DBIx::Class.
+
+=head1 METHODS
+
+=head2 init_schema
+
+ my $schema = DBICTest->init_schema;
+
+=cut
+
+sub _connect_info {
+ my $self = shift;
+ my $db_file = ':memory:';
+
+ my $dsn = "dbi:SQLite:${db_file}";
+ my $dbuser = '';
+ my $dbpass = '';
+
+ my @connect_info = ( $dsn, $dbuser, $dbpass );
+
+ return @connect_info;
+}
+
+sub init_schema {
+ my $self = shift;
+
+ my $schema = TestSchema->connect( $self->_connect_info );
+ $self->deploy_schema($schema);
+ return $schema;
+}
+
+sub deploy_schema {
+ my $self = shift;
+ my $schema = shift;
+
+ open IN, "t/lib/sqlite.sql";
+ my $sql;
+ { local $/ = undef; $sql = <IN>; }
+ close IN;
+ for my $chunk ( split( /;\s*\n+/, $sql ) ) {
+ if ( $chunk =~ / ^ (?! --\s* ) \S /xm )
+ { # there is some real sql in the chunk - a non-space at the start of the string which is not a comment
+ $schema->storage->dbh_do( sub { $_[1]->do($chunk) } ) || warn "Error executing SQL. chunk: $chunk";
+ }
+ }
+ return;
+}
+
+1;
Added: DBIx-Class-DynamicDefault/1.000/branches/post-03_wreis_add_column_bug/t/lib/TestSchema/Extended.pm
===================================================================
--- DBIx-Class-DynamicDefault/1.000/branches/post-03_wreis_add_column_bug/t/lib/TestSchema/Extended.pm (rev 0)
+++ DBIx-Class-DynamicDefault/1.000/branches/post-03_wreis_add_column_bug/t/lib/TestSchema/Extended.pm 2010-05-12 14:19:30 UTC (rev 9360)
@@ -0,0 +1,15 @@
+package TestSchema::Extended;
+
+use strict;
+use warnings;
+use parent 'TestSchema::Table';
+
+__PACKAGE__->table('fubar_extended');
+__PACKAGE__->add_column('extra_field' => {
+ data_type => 'integer',
+ dynamic_default_on_create => 'extra_field_default'
+});
+
+sub extra_field_default { return shift->quux + 1 }
+
+1;
Added: DBIx-Class-DynamicDefault/1.000/branches/post-03_wreis_add_column_bug/t/lib/sqlite.sql
===================================================================
--- DBIx-Class-DynamicDefault/1.000/branches/post-03_wreis_add_column_bug/t/lib/sqlite.sql (rev 0)
+++ DBIx-Class-DynamicDefault/1.000/branches/post-03_wreis_add_column_bug/t/lib/sqlite.sql 2010-05-12 14:19:30 UTC (rev 9360)
@@ -0,0 +1,39 @@
+--
+-- Created by SQL::Translator::Producer::SQLite
+-- Created on Wed Nov 11 12:27:59 2009
+--
+
+
+BEGIN TRANSACTION;
+
+--
+-- Table: affe
+--
+
+CREATE TABLE affe (
+ moo INTEGER PRIMARY KEY NOT NULL,
+ kooh text NOT NULL,
+ baz integer NOT NULL,
+ bar integer NOT NULL
+);
+
+--
+-- Table: fubar
+--
+
+CREATE TABLE fubar (
+ quux INTEGER PRIMARY KEY NOT NULL,
+ garply integer,
+ foo integer NOT NULL,
+ fred text NOT NULL
+);
+
+CREATE TABLE fubar_extended (
+ quux INTEGER PRIMARY KEY NOT NULL,
+ garply integer,
+ foo integer NOT NULL,
+ fred text NOT NULL,
+ extra_field INTEGER NOT NULL
+);
+
+COMMIT;
More information about the Bast-commits
mailing list