[Dbix-class] Automatic quoting

fREW Schmidt frioux at gmail.com
Mon Jun 7 22:04:06 GMT 2010

On Mon, Jun 7, 2010 at 12:04 AM, Toby Corkindale <
toby.corkindale at strategicdata.com.au> wrote:

> On 04/06/10 19:02, Will Hawes wrote:
>> Yesterday a colleague new to DBIC ran into a problem with a column
>> named using a reserved word in MySQL. He worked around it by using a
>> different column name, but while discussing the issue he asked why
>> quote_char and name_sep are not set automatically. I don't know the
>> answer and Googling has left me none the wiser.
>> I'd have thought that if the dsn contains "dbi:mysql", it should be
>> safe to assume that quote_char should be "`" and so on - the unsafe
>> cases being things like "dbi:ODBC" where you can't determine the
>> database from the dsn (although there may be other ways to work it out
>> from $schema->storage->dbh).
>> Is there a reason for only allowing quoting to be set up manually, or
>> is this a case of patches welcome?
> Only speaking on behalf of myself, but I see:
> 1) You shouldn't be making db tables or columns based on reserved words
> anyway, as sooner or later someone will want to log in manually to do
> something in SQL, and be cursing you.
> 2) it makes debugging output much harder to read. (Because it takes up mo=
> space, and also looks ugly.)
I disagree with the former.  What if you have a column like, say, username
or login?  That should be totally allowed.

As for the latter, it *is* true that it makes the sql "grosser" but I don't
really mind that.  I leave it on because I want the safety of it.

Lastly, we do want to do this, as it would help a lot of people, but we are
worried about compatibility, and more likely what we'd do is just allow you
to do: quoting =3D> 1 and it figure out the right quoting for your db.  Wil=
if you'd like to try your hand at it we'd love help on setting it up.  Swing
by the irc channel and we can talk about implementation and getting you a
commit bit.
-- =

fREW Schmidt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20100607/6f3=

More information about the DBIx-Class mailing list