Empty field gets set to 0 when updating bug

David Marshall dmarshal at yahoo-inc.com
Mon Aug 4 16:36:25 UTC 2008




On 8/4/08 8:34 AM, "Andrew Marold" <drew at marold.org> wrote:

> Hi, I'm doing a bunch of customizations to my Bugzilla installation to
> support the way our organization works. To this end I've added a couple
> columns to the bugs tables and the templates. One of them, which is
> meant to track the svn revision number of the bug fix is giving me some
> problems. When I edit a bug if I leave this field empty, it winds up
> getting set to 0. If I set it to some valid valid it gets set properly.
> 
> I've painstakingly tracked the source through the debugger, and all is
> fine until the actual call to the db (mysql in this case) to set the
> values. The sql query string looks right, and the @values array has the
> empty string for my value, yet when the newly updated bug is read back
> in to generate activity entries, my field has been set to 0.
> 

IIRC, the empty string gets "numified" to 0 by MySQL if it's putting it into
a numeric column.  If you really want a NULL, your value needs to be undef.

> I'm kind of at a loss as to where to go next, and would really
> appreciate any suggestions you can offer.
> 
> On a related note, where are you supposed to put validators for new
> fields ? I tried putting some code in run_create_validators() but it
> didn't appear to be getting used. This particular field is never set on
> bug creation, only on subsequent updates.
> 
> Thanks,
> Drew




More information about the developers mailing list