Added the trashed elements to the ID generation query.