def METHOD_NAME(mock_get_fields_function):
    """upsert_data() should raise InvalidDataError if given invalid data.
    If the type of a field is numeric and upsert_data() is given a whitespace
    value like "   ", it should raise DataError.
    In this case we're testing with "method": "insert" in the data_dict.
    """
    mock_connection = mock.Mock()
    mock_connection.execute.side_effect = sqlalchemy.exc.DataError(
        "statement", "params", "orig", connection_invalidated=False
    )
    context = {"connection": mock_connection}
    data_dict = {
        "fields": [{"id": "value", "type": "numeric"}],
        "records": [
            {"value": 0},
            {"value": 1},
            {"value": 2},
            {"value": 3},
            {"value": "   "},  # Invalid numeric value.
            {"value": 5},
            {"value": 6},
            {"value": 7},
        ],
        "method": "insert",
        "resource_id": "fake-resource-id",
    }
    mock_get_fields_function.return_value = data_dict["fields"]
    with pytest.raises(backend.InvalidDataError):
        db.upsert_data(context, data_dict)