BeanieODM / beanie

Asynchronous Python ODM for MongoDB
http://beanie-odm.dev/
Apache License 2.0
1.94k stars 203 forks source link

[BUG] Indecipherable error during first query and no registered doc #764

Open mikeckennedy opened 9 months ago

mikeckennedy commented 9 months ago

Hey Roman. :)

Describe the bug

If you have a large project and forget to include a model in the connection / registration, the error message is super weird.

To Reproduce Try to do a query without passing a document to the models value in the connection, for example:

await BackgroundJob.find(BackgroundJob.processing_status == JobStatus.awaiting).to_list()

if BackgroundJob wasn't registered, the error is:

AttributeError: processing_status

What? There is a processing_status on the class, but the class wasn't registered.

Expected behavior A message like "Cannot query against BackgroundJob, it has not been registered with Beanie"

roman-right commented 8 months ago

Hi @mikeckennedy , Thank you for the catch! I'll pick this up next week during the next bug-fixing session.

mikeckennedy commented 8 months ago

Thanks Roman. :)