﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	resolution	keywords	cc	parents
5079	"Duplicate key error when tagging media ""tag"" and ""#tag"""	ayleph		"I have a user who was getting server errors when uploading media. He was tagging his upload as ""tag,#tag"". ""tag"", ""#tag"", ""Tag"", and possibly other permutations are given the same tag number in my postgresql database.

{{{
mediagoblin-prod=# select distinct tag from core__media_tags where name='tag';
 tag
------
 1742
(1 row)

mediagoblin-prod=# select distinct tag from core__media_tags where name='#tag';
 tag
------
 1742
(1 row)

mediagoblin-prod=# select distinct tag from core__media_tags where name='Tag';
 tag
------
 1742
(1 row)
}}}


This causes a foreign key constraint violation when attempting to add ""#tag"" to `core__media_tags`.

{{{
Error - <class 'sqlalchemy.exc.IntegrityError'>: (IntegrityError) duplicate key value violates unique constraint ""core__media_tags_tag_media_entry_key""
DETAIL:  Key (tag, media_entry)=(337, 3534) already exists.
 'INSERT INTO core__media_tags (media_entry, tag, name) VALUES (%(media_entry)s, %(tag)s, %(name)s) RETURNING core__media_tags.id' {'tag': 337, 'name': u'#tag', 'media_entry': 3534}
}}}

I can reproduce this error by uploading by own media tagged as ""tag,#tag"". Interestingly, if I tag the media as ""tag,tag"" then I do not get the foreign key constraint violation. If we can ignore duplicate identical tags in the upload (tag, tag), then I think it would be good if we could also ignore tags which result in duplicate tag numbers in the table.

breton suggested I tag with under the 0.8.0 milestone."	defect	closed	major	0.9.0	programming	fixed	tags		
