mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
fix for bug with hid starting at 2 instead of 1, introduced by myself at 2bb7df0
This commit is contained in:
@@ -1852,16 +1852,21 @@ class_mapper(model.LibraryDatasetDatasetAssociation).add_property( "creating_job
|
||||
|
||||
def db_next_hid( self ):
|
||||
"""
|
||||
Override __next_hid to generate from the database in a concurrency
|
||||
safe way.
|
||||
db_next_hid( self )
|
||||
|
||||
Override __next_hid to generate from the database in a concurrency safe way.
|
||||
Loads the next history ID from the DB and returns it.
|
||||
It also saves the future next_id into the DB.
|
||||
|
||||
:rtype: int
|
||||
:returns: the next history id
|
||||
"""
|
||||
conn = object_session( self ).connection()
|
||||
table = self.table
|
||||
trans = conn.begin()
|
||||
try:
|
||||
current_hid = select( [table.c.hid_counter], table.c.id == self.id, for_update=True ).scalar()
|
||||
next_hid = current_hid + 1
|
||||
table.update( table.c.id == self.id ).execute( hid_counter = ( next_hid ) )
|
||||
next_hid = select( [table.c.hid_counter], table.c.id == self.id, for_update=True ).scalar()
|
||||
table.update( table.c.id == self.id ).execute( hid_counter = ( next_hid + 1 ) )
|
||||
trans.commit()
|
||||
return next_hid
|
||||
except:
|
||||
|
||||
Reference in New Issue
Block a user