Added to catch ProgrammingError when checking whether a user is in use in the Mia core application.

This commit is contained in:
依瑪貓 2020-08-17 09:29:03 +08:00
parent 35b246077c
commit 5e321ad420

View File

@ -22,7 +22,8 @@ import hashlib
from dirtyfields import DirtyFieldsMixin
from django.conf import settings
from django.db import models, connection, OperationalError, transaction
from django.db import models, connection, OperationalError, transaction, \
ProgrammingError
from django.db.models.functions import Now
from django.urls import reverse
@ -185,6 +186,8 @@ class User(DirtyFieldsMixin, models.Model):
cursor.execute(sql, [self.pk, self.pk])
except OperationalError:
return False
except ProgrammingError:
return False
if cursor.fetchone() is None:
return False
return True