Skip to content

Commit

Permalink
Merge pull request #17486 from ggovi/conddb-utilities-conddb-tool-fix2
Browse files Browse the repository at this point in the history
Fix for conddb edit tool
  • Loading branch information
cmsbuild committed Feb 13, 2017
2 parents 55cfc88 + 7ecd92f commit 5248eca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CondCore/Utilities/python/conddblib.py
Expand Up @@ -265,7 +265,7 @@ class IOV:
columns = { 'tag_name':(DbRef(Tag,'name'),_Col.pk),
'since':(sqlalchemy.BIGINT,_Col.pk),
'insertion_time':(sqlalchemy.TIMESTAMP,_Col.pk),
'payload_hash':(DbRef(Payload,'hash'),_Col.pk) }
'payload_hash':(DbRef(Payload,'hash'),_Col.notNull) }


class GlobalTag:
Expand Down
10 changes: 8 additions & 2 deletions CondCore/Utilities/scripts/conddb
Expand Up @@ -1458,6 +1458,8 @@ def edit(args):
# replaced with the actual insertion times. The format must be
# one of the following: '2013-01-20', '2013-01-20 10:11:12' or
# '2013-01-20 10:11:12.123123'.
# If the insertion time desired is the one of the command execution,
# you can simply write a '-' in the corresponding column
#
# Suggestion: open another terminal to copy the payloads you need.
''' % name)
Expand Down Expand Up @@ -1490,7 +1492,10 @@ def edit(args):
elif len(payload) < conddb.hash_length:
payload = _get_payload_full_hash(session, payload)

insertion_time = _parse_timestamp(insertion_timestamp)
if insertion_timestamp == '-':
insertion_time = datetime.datetime.now()
else:
insertion_time = _parse_timestamp(insertion_timestamp)
new_table.append((int(since), insertion_time, payload))

table = set(table)
Expand Down Expand Up @@ -1539,7 +1544,8 @@ def edit(args):
# Use session.delete() instead of bulk delete to let SQLAlchemy use UPDATE
# (since we may disable DELETE in Oracle for the tables)
for since, insertion_time, _ in deleted:
session.delete(session.query(IOV).get((name, since, insertion_time)))
session.query(IOV).filter(IOV.tag_name==name, IOV.since==since, IOV.insertion_time==insertion_time).delete()
#session.delete(session.query(IOV).filter(IOV.tag_name==name, IOV.since==since, IOV.insertion_time==insertion_time))
for since, insertion_time, payload in added:
if connection.is_official:
insertion_time = datetime.datetime.now()
Expand Down

0 comments on commit 5248eca

Please sign in to comment.