[Bast-commits] r5803 - in DBIx-Class/0.08/trunk: . lib/DBIx/Class t
groditi at dev.catalyst.perl.org
groditi at dev.catalyst.perl.org
Mon Mar 23 18:16:41 GMT 2009
Author: groditi
Date: 2009-03-23 18:16:41 +0000 (Mon, 23 Mar 2009)
New Revision: 5803
Modified:
DBIx-Class/0.08/trunk/Changes
DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSource.pm
DBIx-Class/0.08/trunk/lib/DBIx/Class/Row.pm
DBIx-Class/0.08/trunk/t/66relationship.t
Log:
skip test doc issue relating to db-side defaults
Modified: DBIx-Class/0.08/trunk/Changes
===================================================================
--- DBIx-Class/0.08/trunk/Changes 2009-03-23 15:59:06 UTC (rev 5802)
+++ DBIx-Class/0.08/trunk/Changes 2009-03-23 18:16:41 UTC (rev 5803)
@@ -25,6 +25,8 @@
- support for views both in DBIC and via deploy() in SQLT
- test for not dying if a column isn't loaded after insert and a rel using
it is called. (eg ->new({ name => 'foo'})->bar if bar uses bar_id)
+ - Currently skipped. Changed exception to have a more detailed message
+ - Document the known issue and a possible work around.
0.08099_06 2009-01-23 07:30:00 (UTC)
- Allow a scalarref to be supplied to the 'from' resultset attribute
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSource.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSource.pm 2009-03-23 15:59:06 UTC (rev 5802)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSource.pm 2009-03-23 18:16:41 UTC (rev 5803)
@@ -129,6 +129,9 @@
reference to a scalar e.g. C<\'now()'> if you want a function). This
is currently only used by L<DBIx::Class::Schema/deploy>.
+See the note on L<DBIx::Class::Row/new> for more information about possible
+issues related to db-side default values.
+
=item sequence
Set this on a primary key column to the name of the sequence used to
@@ -1197,7 +1200,11 @@
#warn "$self $k $for $v";
unless ($for->has_column_loaded($v)) {
if ($for->in_storage) {
- $self->throw_exception("Column ${v} not loaded on ${for} trying to resolve relationship");
+ $self->throw_exception(
+ "Column ${v} not loaded or not passed to new() prior to insert()"
+ ." on ${for} trying to resolve relationship (maybe you forgot "
+ ."to call ->reload_from_storage to get defaults from the db)"
+ );
}
return $UNRESOLVABLE_CONDITION;
}
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Row.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Row.pm 2009-03-23 15:59:06 UTC (rev 5802)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Row.pm 2009-03-23 18:16:41 UTC (rev 5803)
@@ -75,6 +75,13 @@
be turned into objects via new_related, and treated as if you had
passed objects.
+Please note that if a value is not passed to new, DBIC will have no knowledge
+of the value unless the value is reloaded, creating the possibility of the row
+object differing from the database value if column defaults are used. To avoid
+this issue you can either pass an explicit undef for nullable columns with a
+NULL as default, or simply call L</discard_changes> on the row object after
+insertion.
+
For a more involved explanation, see L<DBIx::Class::ResultSet/create>.
=cut
Modified: DBIx-Class/0.08/trunk/t/66relationship.t
===================================================================
--- DBIx-Class/0.08/trunk/t/66relationship.t 2009-03-23 15:59:06 UTC (rev 5802)
+++ DBIx-Class/0.08/trunk/t/66relationship.t 2009-03-23 18:16:41 UTC (rev 5803)
@@ -39,7 +39,11 @@
title => 'Big Flop',
year => 2005,
} );
- lives_ok { $big_flop->genre} "Don't throw exception when col is not loaded after insert";
+
+ SKIP:{
+ skip "Can't fix right now", 1 unless $DBIx::Class::VERSION >= '0.09';
+ lives_ok { $big_flop->genre} "Don't throw exception when col is not loaded after insert";
+ };
}
my $big_flop_cd = ($artist->search_related('cds'))[3];
More information about the Bast-commits
mailing list