martell has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks

I'm writing a little Internet application that uses Class::DBI as principle method to access the MySQL database. For this application i use universal unique identifiers, commonly known as guid or uuid's

During testing phase, one of the more elaborate test scripts sometimes generated errors. During investigation it came to me that, when a generated uuid has by coincidence a trailing space as bit presentation, the database would chop it off.

After correcting the database type to a TINYBLOB, the database left the trailing space an kept the guids correctly, but in my perl code the trailing space was still missing.

Reading through the cpan docs of class:dbi i noticed that they set the option 'ChopBlanks' by default on. Further according the doc of DBI, this option should only affect char attributes in the database. My type of attribute is TINYBLOB

_However_, overwriting the option 'ChopBlanks' back to zero solved my problem.

Googling about the option got me only a remark that 'ChopBlanks => 1' set by Class::DBI was maybe a legacy setting and could be ignored. But an annotation in the POD documentation says that what i'm doing is earning a ticket to hell.

So my dear monks, my question to you is:

  • Is setting ChopBlanks => 0 while using Class::DBI really dangerous, and why?
  • Is there another way to guarantee that i have my trailing space in the guid in and out of the DB using Class::DBI?

    Thanks in advance

  • Replies are listed 'Best First'.
    Re: Class::DBI and the ChopBlanks option
    by perrin (Chancellor) on May 18, 2006 at 21:55 UTC
      I think it's fine. I've never been sure why Class::DBI turned that on.
    Re: Class::DBI and the ChopBlanks option
    by runrig (Abbot) on May 18, 2006 at 21:02 UTC
      I don't see what is "dangerous" about setting ChopBlanks to zero (what evidence do you see to suggest that?). It seems to be just an option, one which you'd like to set the way you want. It does seem like there may be a bug in that ChopBlanks is only supposed to affect Char columns, but seems to be affecting your Tinyblob column (I am not sure what a tinyblob is, but if it's the same as a char, then that may be the reason).