Permalink
Browse files

Update player info if it changes due to a new BotParams field.

  • Loading branch information...
1 parent 481a4f6 commit 8dcfba73a756bc76c708ebea366b39a3b7a3b676 @dripton committed Feb 10, 2013
Showing with 8 additions and 3 deletions.
  1. +8 −3 slugathon/net/Results.py
View
11 slugathon/net/Results.py
@@ -97,9 +97,8 @@ def save_game(self, game):
# See if that player is already in the database
query = """SELECT player_id FROM player
- where name = ? AND class = ? AND info = ?"""
- cursor.execute(query, (player.name, player.player_class,
- player.player_info))
+ where name = ? AND class = ?"""
+ cursor.execute(query, (player.name, player.player_class))
row = cursor.fetchone()
# If not, insert it.
if row is None:
@@ -114,6 +113,12 @@ def save_game(self, game):
cursor.execute(query, (player.player_class,
player.player_info))
row = cursor.fetchone()
+ else:
+ player_id = row["player_id"]
+ # We may need to update info, if new fields were added.
+ query = """UPDATE player SET info = ?
+ where player_id = ?"""
+ cursor.execute(query, (player.player_info, player_id))
player_id = row["player_id"]

0 comments on commit 8dcfba7

Please sign in to comment.