Recently a team I support encountered an issue with a value which they were storing in (and retrieving from) a MySQL database. They tell me that they were storing a comma delimited value in a (VARCHAR(255)?) column.
They reported that their value was being silently truncated (their code is mostly Ruby, some other processing is done in Scala) and asked us to double the size of that column.
Naturally I suggested that they normalize ... store each of these values (formerly comma-delimited) in separate rows and use a SELECT to fetch the set (which formerly would have been a single row). They pushed back and insist that they never want these separated values for any other sort of database query and that they'll never need the field to be wider than the new (512) width.
I then suggested that they at least add a sentinel marking the end of their string (a trailing semicolon in particular) and check for that on all fetches. They have implemented that and are happy with the approach.
My questions:
- How did their data get silently truncated? Is there some setting in MySQL or in their DB drivers for Ruby that's suppressing the error?
- What are the pros and cons of this sentinel terminated value vs. a more normalized approach?
- Is there some term of art or nickname for this sentinel terminated value?
- What would be a better way to address their issue?