Added extra code to handle the case of Oracle which saves empty strings as null values. Backport of 05dc694c from master