Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions inventoryctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def _group_update(self, gname, groups):
group = groups[gname]
parent = None
if self.args.parent in groups:
parent = group[self.args.parent]
parent = groups[self.args.parent]

if self.args.update:
print('Update mode')
Expand Down Expand Up @@ -400,8 +400,9 @@ def _group_update(self, gname, groups):

# modify parent group
if parent is not None:
sql = """UPDATE `childgroups` SET `parent_id` = %d WHERE `child_id` = %d;"""
affected_rows += self.__cursor.execute(sql % (group['id'], parent['id']))
sql = """INSERT INTO `childgroups` (`child_id`,`parent_id`) VALUES
(%d,%d) ON DUPLICATE KEY UPDATE `child_id` = %d, `parent_id` = %d;"""
affected_rows += self.__cursor.execute(sql % (group['id'], parent['id'], group['id'], parent['id']))

self.conn.commit()

Expand Down