[CDBI] Re: Reserved words in MySQL
"Edward J. Sabol" <sabol-2oVx0MVsMgiP/[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.class-dbi |
|---|---|
| Message-ID | <[email protected]> |
> I fixed the db creation scripts by wrapping the table names in
> backticks (``), but I can't control how Class::DBI builds its SQL.
> It'd be great if this could be turned on somewhere globally.
>
> Any thoughts?
Well, I would just bite the bullet and rename the table personally, but if
some requirement makes that impossible, I suppose I would try subclassing
Class::DBI::SQL::Transformer. This subclass should override the
_expand_table() method to put backticks around the table name if and only if
the table name is "Connection" (or some other MySQL reserved word). Then, in
my CDBI base class, add the following:
__PACKAGE__->sql_transformer_class('My::Class::DBI::SQL::Transformer');
where My::Class::DBI::SQL::Transformer is my subclass of
Class::DBI::SQL::Transformer.
This is uncharted territory, and I have no idea if that would work or not. I
think it should work though. Good luck.
Hope this helps,
Ed