Make query for adding to database have correct syntax: quoted or non-quoted value depending on type.