MongoEngine/mongoengine

Unable to Access Renamed Column 'woocomerce_id' in MongoEngine

kmikodev opened this issue · 1 comments

Steps to Reproduce:

  1. Update the column name from 'ID' to 'woocomerce_id' in the 'Orders' collection using pymongo.
  2. Verify that all documents now have the 'woocomerce_id' property in the database.
  3. Use MongoEngine to retrieve and access the 'woocomerce_id' property from the 'Orders' collection.
  4. Observe the error message: "'Orders' object has no attribute 'woocomerce_id'".

Expected Behavior:
The attribute 'woocomerce_id' should be accessible using the MongoEngine model 'Orders'.

Actual Behavior:
Attempting to access 'woocomerce_id' using the MongoEngine model 'Orders' results in the mentioned error.

Additional Information:

  • I have verified that the model 'Orders' in MongoEngine has been updated to reflect the column name change.
  • The pymongo implementation works correctly, and I can access the 'woocomerce_id' property using pymongo.
  • When accessing the 'woocomerce_id' property using pymongo, the field is accessible without any issues.
  • Restarting the application did not resolve the issue.
  • Other attributes of the 'Orders' model can be accessed without any problems.

Environment:

  • Python version: 3.2
  • MongoEngine version: 0.27.0
  • pymongo version: 4.4.1
  • Operating System: Ubuntu 22.04

Code Snippets:

# Model definition in MongoEngine
class Orders(Document):
    woocomerce_id = StringField()
    # Other fields

# Accessing the property in the application
order_mongoengine = Orders.objects(id=id).first()
woocomerce_id_value = order_mongoengine.woocomerce_id  # This line triggers the error

It is working fine with simple cases so probably there are additional things that makes this not working

image

Send an example of your pymongo documents that is failing + your actual Model/Document definition, there has to be some mismatches between the two.