[CDBI] Quoting reserved words.

Edward J. Sabol Edward.J.Sabol at nasa.gov
Thu Jan 14 05:49:22 GMT 2010

Bill Moseley wrote:
> Client upgraded to Postgresql 8.4 and started seeing this: DBD::Pg::st
> execute failed: ERROR: syntax error at or near "window"
> Where "window" happens to be a column name in a class.
> I remember that you can create an alias for a table name to deal with
> reserved words, but I don't remember how to deal with column names that
> are reserved words.

Have you tried specifying the column name as '"window"'? A similar trick
mostly worked for table names. I suspect it won't work as well for column
names though. You'd probably need at least custom
accessor_name_for/mutator_name_for methods to remove the quotes.

I looked over my personal archive of the mailing list going back to 2003, and
the only real discussion (and solutions) I found dealt with table names. The
one time I found where column names came up, in December 2006, I suggested
subclassing Class::DBI::SQL::Transformer to do what you need in an API-clean
way, but that was just theoretical. Nobody's ever tried it, AFAIK.

> Found this: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=361533

Well, that's some interesting stuff. Those changes look pretty reasonable to

Alternatively, you could make a view in the database that is basically
identical to the table in question but with the "window" column name changed
to something else.

Hope this helps,

More information about the ClassDBI mailing list