Why Display Unit Dropdowns Should Never Write to the Database
A support ticket reveals two users seeing different values for the same record, with no errors logged to explain the discrepancy. The culprit is often a UI dropdown for switching units that writes converted values back into the model. Repeated conversions cause rounding drift, and saving a form after only changing the display unit can silently corrupt the stored quantity. The recommended fix is to store one canonical unit per quantity type, encode that unit in the column name, such as mass_g, and keep display units as view-only state. Conversions should occur only at the input and output edges, and the model should not carry a unit field that could persist an inconsistent value.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in