Closed BraveEggTart closed 3 weeks ago
Hi!
Sorry for confusion - just merged https://github.com/tortoise/tortoise-orm/pull/742 which did basically the same few hours before Still hope your problem is resolved by merged change, I will release it as 0.21.4 a little bit later
Description
Add the model.name field to the DoesNotExist and MultipleObjectsReturned exception message to obtain clearer prompts when calling the model. get() method.
Motivation and Context
When I use the Model.get() method and a DoesNotExist exception occurs because there is no corresponding record in the database, the provided error message is often not specific enough for me to quickly identify which Model is involved. The message "Object does not exist" is too generic.
#1635
How Has This Been Tested?
I executed the
make test
command and passed all tests related to the get() method, such as thetest_get
method intest_queryset.py
.testing environment: python: 3.10.6
There's something I need to say. I checked the code about DoesNotExist and MultipleObjectsReturned, and noticed that in the _getbypk method of models.py, DoesNotExist was processed and returned cls._meta.full_name, Is this a place that needs to be modified synchronously?
Checklist: