Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-2680

Automatically convert empty string properties on OpenmrsObjects to null before persisting in the database

    XMLWordPrintable

    Details

    • Complexity:
      Low

      Description

      See https://groups.google.com/a/openmrs.org/group/dev/browse_thread/thread/c12d7c572ea96035/92c027b827f5cccb?utoken=0pxm8yYAAADO4ngf8ivDo7BdQvaWMREJnOtFmdWsPTkQg9GYhcycP3dsec8RJEP-5yKaIBYaqmM#

      The reasoning:

      • we can't think of any case where "" and null are semantically different
      • some databases (e.g. Oracle) don't support storing empty strings in varchar fields
      • "" is a cheating way around a not-null constraint

      Proposal:

      • In OpenmrsObjectSaveHandler, iterate over all fields (presumably using commons-beanutils PropertyUtils or BeanUtils) and any fields of String type whose value is "" should be set to null.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dkayiwa Daniel Kayiwa
              Reporter:
              darius Darius Jazayeri [X] (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: