Fix tagging resources with custom tags
Before this commit, on some versions custom tags weren't given
a comment, so the comment was NULL in the database. Comparing
NULL to NULL obviously is always false, so tag wasn't equal to itself.
This commit ensures that tags are compared only by id.