D-backs avoid sweep in San Diego