?

Log in

No account? Create an account

Previous Entry | Next Entry

Death to reserved words

Knightley has a feature called "groups". This has proven to be a huge liability.

You see, SQL (the language used to talk to databases) has a feature called GROUP BY. I won't bother explaining what it does, but there's basically only one place in SQL where you could possibly use the word "GROUP" (or "group" or "GrOUp", since SQL is case-insensitive) to access that feature.

Naturally, having a feature called "groups", I want to be able to call things in my database "group". Unfortunately, for some insane reason, SQL uses reserved words--meaning that using "GROUP" in any context, even one that clearly has nothing to do with GROUP BY, is verboten. There are quoting mechanisms for getting around this, but they vary from database to database, so the library I'm using doesn't try to support them.

And now it's having trouble renaming a column named 'group' to 'groupid' for some reason...

Ugh.

Comments

( Read 2 comments — Leave a comment )
shamess_the_elf
Sep. 29th, 2006 07:10 am (UTC)
Have you tried using back ticks (the button below your escape cape) around the table/column name? That usually works, but I'm using MySQL, not SQL as such, so that's all I got.
brentdax
Sep. 29th, 2006 07:43 am (UTC)
I'm using MySQL too, but I'm also using a Perl module called DBIx::Class which writes the SQL for me. (It makes rows in the database look like objects that I can then manipulate in various interesting ways.) So backticking everything would require me to edit every SQL statement in a giant suite of modules. Which would be...annoying.
( Read 2 comments — Leave a comment )