Hi All, The way that our webapp, our API, and the DB interact, we frequently run into the case where we store empty strings in the database for values, when they really should be null.
For example if you save a Concept Source and leave the HL7 Code field blank, you save a row with concept_source.hl7_code = '' rather than null. (Because the webapp submits an empty input, and we use spring MVC to bind that to a bean property.) Two tickets that I looked at today are related to this (and there are certainly others): https://tickets.openmrs.org/browse/TRUNK-2516 https://tickets.openmrs.org/browse/TRUNK-2004 We should try to fix this problem in a general way. At first thought I can't come up with a case where we really want to save the empty string in a database field rather than null. So some possible solutions are: - (at the web level) use a custom PropertyEditor for the String class in all our Spring controllers, so that if you submit "" and bind that to a String property, it sets it to null. - (at the API level) in OpenmrsObjectSaveHandler iterate over all String properties and if any of them are "" then set them to null. (The first would allow API consumers to explicitly set empty string properties on objects, while the second wouldn't.) Any thoughts on this? _________________________________________ To unsubscribe from OpenMRS Developers' mailing list, send an e-mail to [email protected] with "SIGNOFF openmrs-devel-l" in the body (not the subject) of your e-mail. [mailto:[email protected]?body=SIGNOFF%20openmrs-devel-l]

