Improve sql string literal escaping

Related to #630 
for all of these Functions, wouldn't it be safer to use String.valueOf() or use a nullcheck, just in case?