Flush once per tag

Not sure this is the right thing to do (maybe there is a better way to get an ID?), but it avoids
```
IntegrityError: (psycopg2.IntegrityError) duplicate key value violates unique constraint "tag_name_key"
DETAIL:  Key (name)=(group) already exists.
 [SQL: 'INSERT INTO tag (type, parent_id, name) VALUES (%(type)s, %(parent_id)s, %(name)s) RETURNING tag.id'] [parameters: {'parent_id': None, 'type': 0, 'name': u'group'}]
galaxy.tools.execute WARNING 2018-02-06 15:22:38,808 [p:2122,w:1,m:0] [uWSGIWorker1Core1] There was a failure executing a job for tool [__TAG_FROM_FILE__] - Error executing tool: (psycopg2.IntegrityError) duplicate key value violates unique constraint "tag_name_key"
```
This commit is contained in:
mvdbeek
2018-02-07 10:58:58 +01:00
parent e306a447c0
commit d14bae73f7
3 changed files with 8 additions and 6 deletions
+2
View File
@@ -169,6 +169,8 @@ class TagManager(object):
item_tag_assoc.user_tname = name
item_tag_assoc.user_value = value
item_tag_assoc.value = lc_value
# Need to flush to get an ID. We need an ID to apply multiple tags with the same tname to an object.
self.sa_session.flush()
return item_tag_assoc
def apply_item_tags(self, user, item, tags_str):
@@ -34,13 +34,13 @@
<assert_contents>
<has_text_matching expression="^This is a line of text.\n$" />
</assert_contents>
<metadata name="tags" value="alias:r1,orientation:forward" />
<metadata name="tags" value="alias:f,alias:r1,orientation:forward" />
</element>
<element name="reverse">
<assert_contents>
<has_text_matching expression="^This is a different line of text.\n$" />
</assert_contents>
<metadata name="tags" value="alias:r2,orientation:reverse" />
<metadata name="tags" value="alias:r,alias:r2,orientation:reverse" />
</element>
</output_collection>
</test>
@@ -63,13 +63,13 @@
<assert_contents>
<has_text_matching expression="^This is a line of text.\n$" />
</assert_contents>
<metadata name="tags" value="alias:r1,orientation:forward" />
<metadata name="tags" value="alias:f,alias:r1,orientation:forward" />
</element>
<element name="reverse">
<assert_contents>
<has_text_matching expression="^This is a different line of text.\n$" />
</assert_contents>
<metadata name="tags" value="alias:r2,orientation:reverse" />
<metadata name="tags" value="alias:r,alias:r2,orientation:reverse" />
</element>
</element>
</output_collection>
+2 -2
View File
@@ -1,2 +1,2 @@
forward orientation:forward alias:r1
reverse orientation:reverse alias:r2
forward orientation:forward alias:r1 alias:f
reverse orientation:reverse alias:r2 alias:r