I was just tinkering with the loader, and might have found a bug.
Create two tables:
--
-- Table structure for table `attribute_types`
--
CREATE TABLE IF NOT EXISTS `attribute_types` (
`id` bigint(20) unsigned NOT NULL auto_increment,
`name` varchar(255) NOT NULL,
`table_name` varchar(255) NOT NULL,
`datatype_id` bigint(20) unsigned NOT NULL,
PRIMARY KEY (`id`),
KEY `name` (`name`),
KEY `datatype_id` (`datatype_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `datatypes`
--
CREATE TABLE IF NOT EXISTS `datatypes` (
`id` bigint(20) unsigned NOT NULL auto_increment,
`name` varchar(255) NOT NULL,
`format` varchar(255) NOT NULL default '.*',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `attribute_types`
--
ALTER TABLE `attribute_types`
ADD CONSTRAINT `attribute_types_ibfk_1` FOREIGN KEY (`datatype_id`)
REFERENCES `datatypes` (`id`);
--
-- Constraints for table `datatypes`
--
ALTER TABLE `datatypes`
ADD CONSTRAINT `datatypes_ibfk_1` FOREIGN KEY (`id`) REFERENCES
`attribute_types` (`datatype_id`) ON DELETE CASCADE ON UPDATE NO
ACTION;
Then copy/paste from the loader example code:
use My::DB;
use Rose::DB::Object::Loader;
my $loader = Rose::DB::Object::Loader->new(db => My::DB->new,
class_prefix => 'My::DB');
my @classes = $loader->make_classes;
foreach my $class (@classes) {
if($class->isa('Rose::DB::Object')) {
print $class->meta->perl_class_definition(braces =>
'k&r',indent => 2),"\n";
}
else {
print $class->perl_class_definition,"\n";
}
---
Running the above code dies:
Cannot make 'delete_on_save' method delete_attribute_type without
relationship argument at
/usr/lib/perl5/site_perl/5.8.8/Rose/DB/Object/MakeMethods/Generic.pm
line 3756
Dropping the `datatypes_ibfk_1` constraint allows the script to finish.
Any tips?
Justin
-------------------------------------------------------------------------
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