[Bast-commits] r4531 - in DBIx-Class-DynamicDefault/1.000/trunk: .
t t/lib t/lib/TestSchema
rafl at dev.catalyst.perl.org
rafl at dev.catalyst.perl.org
Sun Jun 29 23:25:26 BST 2008
Author: rafl
Date: 2008-06-29 23:25:26 +0100 (Sun, 29 Jun 2008)
New Revision: 4531
Added:
DBIx-Class-DynamicDefault/1.000/trunk/t/
DBIx-Class-DynamicDefault/1.000/trunk/t/lib/
DBIx-Class-DynamicDefault/1.000/trunk/t/lib/TestSchema.pm
DBIx-Class-DynamicDefault/1.000/trunk/t/lib/TestSchema/
DBIx-Class-DynamicDefault/1.000/trunk/t/lib/TestSchema/Table.pm
Log:
Add a test schema.
Added: DBIx-Class-DynamicDefault/1.000/trunk/t/lib/TestSchema/Table.pm
===================================================================
--- DBIx-Class-DynamicDefault/1.000/trunk/t/lib/TestSchema/Table.pm (rev 0)
+++ DBIx-Class-DynamicDefault/1.000/trunk/t/lib/TestSchema/Table.pm 2008-06-29 22:25:26 UTC (rev 4531)
@@ -0,0 +1,45 @@
+use strict;
+use warnings;
+
+package TestSchema::Table;
+
+use parent 'DBIx::Class';
+
+__PACKAGE__->load_components(qw/DynamicDefault Core/);
+__PACKAGE__->table('fubar');
+
+__PACKAGE__->add_columns(
+ quux => {
+ data_type => 'integer',
+ dynamic_default_on_create => 'quux_default',
+ },
+ garply => {
+ data_type => 'integer',
+ is_nullable => 1,
+ dynamic_default_on_update => sub { return $$ },
+ },
+ corge => {
+ data_type => 'integer',
+ dynamic_default_on_create => \&corge_default,
+ dynamic_default_on_update => 'corge_default',
+ },
+);
+
+__PACKAGE__->set_primary_key(qw/quux/);
+
+{
+ my $i = 0;
+
+ sub quux_default {
+ return ++$i;
+ }
+}
+
+sub corge_default {
+ my ($self) = @_;
+
+ return 'update' if $self->in_storage;
+ return 'create';
+}
+
+1;
Added: DBIx-Class-DynamicDefault/1.000/trunk/t/lib/TestSchema.pm
===================================================================
--- DBIx-Class-DynamicDefault/1.000/trunk/t/lib/TestSchema.pm (rev 0)
+++ DBIx-Class-DynamicDefault/1.000/trunk/t/lib/TestSchema.pm 2008-06-29 22:25:26 UTC (rev 4531)
@@ -0,0 +1,10 @@
+use strict;
+use warnings;
+
+package TestSchema;
+
+use parent 'DBIx::Class::Schema';
+
+__PACKAGE__->load_classes;
+
+1;
More information about the Bast-commits
mailing list