[Dbix-class] Quoting table aliases
Matt S Trout
dbix-class at trout.me.uk
Fri Mar 10 14:05:20 CET 2006
Dmitri Bichko wrote:
> Hi,
>
> Would it be possible to have DBIx::Class always quote all table
> identifiers to avoid namespace conflicts?
>
> For example, here's the SQL generated for a many-to-many relationship I
> have:
>
> SELECT group.group_id, group.type, group.name, group.description FROM
> categories me JOIN groups group ON ( group.group_id = me.group_id )
> WHERE ( me.sample_id = 58471)
>
> Since group is a database keyword, Postgres doesn't like it. Easy to
> work around in this case, but is there a reason NOT to add the quotes?
> I guess another way to do it would be to add a DBIC-specific prefix to
> the autogenerated table aliases.
Quoting is supported but turned off by default (it's a bit of a performance
hit during the SQL generation).
$schema->storage->sql_maker->quote_char("`");
$schema->storage->sql_maker->name_sep(".");
should do the trick for you,
> PS Just wanted to say Thank You for DBIC - after years of headaches with
> Class::DBI, it's just a pleasure to work with.
That was the object of the exercise. Thanks :)
--
Matt S Trout Offering custom development, consultancy and support
Technical Director contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd. mst (at) shadowcatsystems.co.uk for more information
+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +
More information about the Dbix-class
mailing list