set id to -1 if not set (redmine #1665)