bug #66: SQL implicit conversion of int to string causes Redmine 500 error

Change-Id: I9ad796998c3555d5a3b367c8823b90f58744dd04

Fix for PostgreSQL.  Also confirmed that it works on MySQL.

More thorough testing will be needed to see if ALL features now work on PostgreSQL, but everything I've tested thus far does work.