split typecast method into two

one method for fetching data and one for sending to db.

fixes #2287
Cool. I think everything looks great to me.