Skip to content
Snippets Groups Projects
Commit c1a9b13b authored by Pavel Kácha's avatar Pavel Kácha
Browse files

Fixed first client's access without id (IndexError: tuple index out of range)...

Fixed first client's access without id (IndexError: tuple index out of range) (thanks to Radko Krkos)
parent 809f56f2
No related branches found
No related tags found
No related merge requests found
...@@ -726,10 +726,15 @@ class MySQL(ObjectReq): ...@@ -726,10 +726,15 @@ class MySQL(ObjectReq):
def getLastReceivedId(self, client): def getLastReceivedId(self, client):
row = self.query("SELECT event_id as id FROM last_events WHERE client_id = %s ORDER BY last_events.id DESC LIMIT 1", (client.id,))[0] res = self.query("SELECT event_id as id FROM last_events WHERE client_id = %s ORDER BY last_events.id DESC LIMIT 1", client.id)
try:
id = row['id'] if row is not None else 0 row = res[0]
logging.debug("getLastReceivedId: id %i for client %i(%s)" % (id, client.id, client.hostname)) except IndexError:
id = None
logging.debug("getLastReceivedId: probably first access, unable to get id for client %i(%s)" % (client.id, client.hostname))
else:
id = row["id"]
logging.debug("getLastReceivedId: id %i for client %i(%s)" % (id, client.id, client.hostname))
return id return id
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment