fix toDatabase value type check