Hi there, I'm seeing the following behaviour with Rose::DB::Object 0.756:
Here's a simple product/vendor relationship with the recommended MySQL tweaks: CREATE TABLE vendors ( id INTEGER PRIMARY KEY AUTO_INCREMENT, name VARCHAR(255) ) Type=InnoDB; CREATE TABLE products ( id INTEGER PRIMARY KEY AUTO_INCREMENT, name VARCHAR(255), vendor_id INTEGER, FOREIGN KEY (vendor_id) REFERENCES vendors(id), INDEX(vendor_id) ) Type=InnoDB; But when I retrieve a product, update its vendor and then run update(), the vendor key gets nuked: mysql> select * from products; +----+--------------+-----------+ | id | name | vendor_id | +----+--------------+-----------+ | 1 | otherproduct | NULL | +----+--------------+-----------+ 1 row in set (0.00 sec) Here's the code that causes this: use strict; use Rose::DB::Object::Loader; my $loader = Rose::DB::Object::Loader->new( db_dsn => 'dbi:mysql:dbname=testdb2', db_username => 'root', db_options => { AutoCommit => 1, ChopBlanks => 1, RaiseError => 1 }, class_prefix => 'My'); $loader->make_classes(); # Create a product and a vendor my $p = My::Product->new(name => "myproduct"); $p->vendor({name => "myvendor"}); $p->save(); # Now retrieve the product my $found = My::Product::Manager->get_products( query => [ name => 'myproduct' ], require_objects => ['vendor'], ); for my $product (@$found) { print "Product: ", $product->name(), " Vendor: ", $product->vendor()->name(), "\n"; } $found->[0]->name("otherproduct"); $found->[0]->vendor({name => "othervendor"}); $found->[0]->update(); The problem doesn't occur if the line $found->[0]->vendor({name => "othervendor"}); gets taken out. If the database requires NOT NULL for the vendor key, the update() operation causes a DB error. Any hints? -- Mike Mike Schilli [EMAIL PROTECTED] ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object