|
|
Mozy Online Backup: 2GB Free. Automatic. Secure.
Subject: RDBO::save with cascade and changes_only - msg#00089
List: lang.perl.modules.dbi.rose-db-object
Hello John,
I think I hited a bug in RDBO, in
$object->save( cascade => 1, changes_only => 1)
for objects implied in a relationship one-to-one.
When adding a new sub-object to an existing main
object and that will try to save self in db, if none of
his fields are modified, the generated sql is incomplete and wrong:
"UPDATE table SET
where id = $1"
I've attached a script for SQLite, but the same behaviour is for
Postgresql.
Best regards,
Lucian Dragus
save-cascade.pl
Description: Binary data
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642_______________________________________________
Rose-db-object mailing list
Rose-db-object-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@xxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/rose-db-object
Was this page helpful?
Thread at a glance:
Previous Message by Date:
click to view message preview
Re: Multiple foreign keys to the same table
On 10/25/06, John Siracusa <siracusa-Re5JQEeQqe8AvxtiuMwx3w@xxxxxxxxxxxxxxxx>
wrote:
> Still working, but I think I'm in the home stretch... :)
Okay, it's documented and in SVN. All tests seem to pass. Let me
know how it works for you.
-John
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Next Message by Date:
click to view message preview
Re: RDBO::save with cascade and changes_only
On 10/26/06 4:09 PM, Lucian Dragus wrote:
> I think I hited a bug in RDBO, in
>
> $object->save( cascade => 1, changes_only => 1)
>
> for objects implied in a relationship one-to-one.
>
> When adding a new sub-object to an existing main
> object and that will try to save self in db, if none of
> his fields are modified, the generated sql is incomplete and wrong:
>
> "UPDATE table SET
> where id = $1"
Fixed in SVN. Thanks for the great bug report! I used your sample code to
create the test for this in the test suite :)
-John
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Previous Message by Thread:
click to view message preview
possible bug fix ( more like a fix for bugs in other places ) + suggestion
I've been going a bit crazy with the to/from yaml for serialization
I noticed that YAML::Syck / JSON::Syck can sometimes have a blank
line in it, which can screw the parser up, and then the rose reader
This will fix it:
next unless $column;
where?
Rose::DB::Object::Helpers
sub init_with_yaml
sub init_with_json
sub init_with_yaml
{
my($self, $yaml) = @_;
my $hash = YAML::Syck::Load($yaml);
my $meta = $self->meta;
local $self->{STATE_LOADING()} = 1;
while(my($column, $value) = each(%$hash))
{
next unless $column;
my $method = $meta->column($column)->mutator_method_name;
$self->$method($value);
}
return $self;
}
sub init_with_json
{
my($self, $json) = @_;
my $hash = JSON::Syck::Load($json);
my $meta = $self->meta;
local $self->{STATE_LOADING()} = 1;
while(my($column, $value) = each(%$hash))
{
next unless $column;
my $method = $meta->column($column)->mutator_method_name;
$self->$method($value);
}
return $self;
}
Also....
what about consolidating both functions a bit, and adding
'init_with_hashref' ?
i say this because:
a- i'm using an init_with_hashref already
b- init_with_yaml / init_with_json have 80% of the same
functionality. we could save some memory here.
so....
sub init_with_hashref
{
my($self, $hashref) = @_;
my $meta = $self->meta;
local $self->{STATE_LOADING()} = 1;
while(my($column, $value) = each(%$hashref))
{
next unless $column;
my $method = $meta->column($column)->mutator_method_name;
$self->$method($value);
}
return $self;
}
sub init_with_yaml
{
my($self, $yaml) = @_;
my $hash = YAML::Syck::Load($yaml);
$self-> init_with_hashref( $hash );
return $self;
}
sub init_with_json
{
my($self, $json) = @_;
my $hash = JSON::Syck::Load($json);
$self-> init_with_hashref( $hash );
return $self;
}
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Next Message by Thread:
click to view message preview
Re: RDBO::save with cascade and changes_only
On 10/26/06 4:09 PM, Lucian Dragus wrote:
> I think I hited a bug in RDBO, in
>
> $object->save( cascade => 1, changes_only => 1)
>
> for objects implied in a relationship one-to-one.
>
> When adding a new sub-object to an existing main
> object and that will try to save self in db, if none of
> his fields are modified, the generated sql is incomplete and wrong:
>
> "UPDATE table SET
> where id = $1"
Fixed in SVN. Thanks for the great bug report! I used your sample code to
create the test for this in the test suite :)
-John
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
|
|