[Catalyst] CDBI::Sweet and accessor_name
Cory Watson
jheephat at gmail.com
Tue Oct 25 18:27:57 CEST 2005
The CDBI::Sweet documentation says to ask questions here, so I shall.
When I add Sweet to the mix (by changing my Foo/DBI.pm to use base
Class::DBI::Sweet) has_many relationships start acting silly. When I
try to delete a Category which is mapped to a Product via a
ProductCategory class, link table, and has_many(categories =>
['Foo::ProductCategory' => 'category']) I get an error. The error
stems from the fact that I have an accessor_name method which trims
'_id$' from the end of any accessors. In other words, category_id
and product_id accessors become 'product' and 'category'.
This seems to confuse Sweet. Removing it puts things back to
normal. Then I lose that lovely page() method that sweet adds. I
want have my Sweets and eat them too! ;)
Any ideas why Sweet is not playing nice with a mapped has_many +
accessor_name? I can change the has_many above to use either
'category_id' or 'category' and get:
Caught exception "Foo:ProductCategory can't SELECT m.product_id,
me.category_id
FROM product_categories me WHERE (me.category = ?)
as it tries to use the accessor name.
I've looked at the line that throws the error (Class/DBI/Relationship/
HasMany.pm line 61) but since I don't understand the data structures
involved I thought I'd ask before going spelunking.
Cory Watson
http://www.onemogin.com
More information about the Catalyst
mailing list