db bug fix
This commit is contained in:
@@ -658,12 +658,16 @@ class Database:
|
|||||||
Returns:
|
Returns:
|
||||||
Optional[int]: the id of the professor, if the professor is not found, None is returned
|
Optional[int]: the id of the professor, if the professor is not found, None is returned
|
||||||
"""
|
"""
|
||||||
|
# get list of all current profs
|
||||||
|
profs = self.getProfs()
|
||||||
|
if profs == []:
|
||||||
|
return 1
|
||||||
data = self.getProfByName(prof_name.replace(",", ""))
|
data = self.getProfByName(prof_name.replace(",", ""))
|
||||||
if data is None:
|
if data is None:
|
||||||
# get last used id and return id + 1
|
# get last used id and return id + 1
|
||||||
profno = self.query_db("SELECT id FROM prof ORDER BY id DESC", one=True)[0]
|
profno = self.query_db("SELECT id FROM prof ORDER BY id DESC", one=True)[0]
|
||||||
return profno + 1
|
return profno + 1
|
||||||
|
|
||||||
# return None
|
# return None
|
||||||
else:
|
else:
|
||||||
return data[0]
|
return data[0]
|
||||||
|
|||||||
Reference in New Issue
Block a user