fixes an issue with null values in write SQL statements
cleanup