Monday, May 12, 2008

SQL Keywords As Column Names

Once in a while, I got caught by my own mistake by using SQL keywords as column names. For example, this looks pretty harmless (but it fails in GORM):

class Person {
String userName
String password
String group

There are 2 problems:

  1. password is a keyword in MySQL.

  2. group is an SQL keyword.

Although it usually doesn't take me too long to realize my mistake, it is a nuisance that I'd rather live without. There is a more systematic way to detect such problem.