On Sun, Feb 03, 2008 at 04:21:26PM -0500, John Siracusa wrote:
> On Feb 3, 2008 3:59 PM, Grzegorz Nosek <[EMAIL PROTECTED]> wrote:
> > my ($a_foo) = @{ Foo::Manager->get_objects( query => [ id => 5, is_even =>
> > 0 ] ) };
> > $a_foo->v2( 5 );
> > $a_foo->save( changes_only => 1 );
> >
> > After executing the above snippet, RDBO wants to update the is_even
> > column and gets barfed at by PostgreSQL (there's no is_even column).
>
> One quick fix might be to convince RDBO that the column is not
> modified, perhaps by adding an on_set trigger to that "fake" is_even
> column that uses the unset_column_value_modified() utility function:
>
> http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Util.pm#unset_column_value_modified
Wow, that was fast! :)
Thanks a lot for your response.
I put something like below in my model class file (after meta->setup and
meta->make_manager_class -- also tried before make_manager_class):
__PACKAGE__
->meta->column('is_even')
->add_trigger('on_set',
sub {
unset_column_value_modified( $_[0], 'is_even' )
});
R::DB::O::Util is imported earlier with :columns
But unfortunately, no go (no observable change in behaviour). Is this the
right way to set up the trigger? After sticking a die in the callback
the code survived too.
> > I'm using RDBO v.0.763.
>
> ...I suggest getting the latest RDBO and then report back if the
> Manager call still results in an object whose is_even column is marked
> as modified. (And even if it's still a problem, you should consider
> upgrading anyway. Many important bugs have been fixed between 0.763
> and now :)
Got 0.7662. Reporting back. Still no go. The column is marked modified.
BTW, below is the patch I'm using. If you could have a look at it and
check for obvious blunders, I'd be very grateful. I'm including it for
the off chance that I broke something by using it.
Best regards,
Grzegorz Nosek
diff --git a/DB/Object/Metadata.pm b/DB/Object/Metadata.pm
index 7ae8cc0..d291542 100755
--- a/DB/Object/Metadata.pm
+++ b/DB/Object/Metadata.pm
@@ -2665,7 +2665,7 @@ sub select_nonlazy_columns_string_sql
my($self, $db) = @_;
return $self->{'select_nonlazy_columns_string_sql'}{$db->{'id'}} ||=
- join(', ', map { $_->select_sql($db) } $self->nonlazy_columns);
+ join(', ', map { $_->select_sql($db, $self->table) }
$self->nonlazy_columns);
}
sub select_columns_string_sql
@@ -2673,7 +2673,7 @@ sub select_columns_string_sql
my($self, $db) = @_;
return $self->{'select_columns_string_sql'}{$db->{'id'}} ||=
- join(', ', map { $_->select_sql($db) } $self->columns_ordered);
+ join(', ', map { $_->select_sql($db, $self->table) }
$self->columns_ordered);
}
sub select_columns_sql
diff --git a/DB/Object/QueryBuilder.pm b/DB/Object/QueryBuilder.pm
index 44f1421..76ca5d0 100755
--- a/DB/Object/QueryBuilder.pm
+++ b/DB/Object/QueryBuilder.pm
@@ -348,8 +348,8 @@ sub build_select
else
{
push(@select_columns,
- $obj_meta ? $obj_meta->column($column)->select_sql($db) :
- $db ? $db->auto_quote_column_name($column) : $column);
+ $obj_meta ? $obj_meta->column($column)->select_sql($db, $table) :
+ $db ? $table . '.' . $db->auto_quote_column_name($column) :
$fq_column);
}
}
@@ -411,7 +411,7 @@ sub build_select
my $placeholder = $col_meta ? $col_meta->query_placeholder_sql($db)
: '?';
my $sql_column = $table_aliases ? $short_column :
- $db ? $db->auto_quote_column_name($column) :
$column;
+ $db ? $table . '.' .
$db->auto_quote_column_name($column) : $fq_column;
if($val_ref)
{
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Rose-db-object mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rose-db-object