Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have field "id" distinct from "_id"; mongodb-engine seems to map the former to the latter #206

Open
prseshad opened this issue Mar 23, 2015 · 0 comments

Comments

@prseshad
Copy link

Hi

I am new to mongodb-engine and am enjoying it. Ran into an issue, and apologies if this is not the right forum or if it's already been answered.

I have documents in one of my tables that have both an _id field, for the ObjectId, and an id field, which is not a pk, like this:

"_id": {
"$oid": "5505e78068bd7bdc667c1926"
},
"id": 1114157,
"duplicates": [],
"application_ids": [
1125668
],

I am trying to access the "id" field through a field called "candidate_id" (since I can't name it id, as that field name is reserved for pk's), like this:

class DedupedCandidate(models.Model):
class Meta:
db_table = 'deduped_candidates'

candidate_id = models.IntegerField(db_column='id')
application_ids = IntListOverrideField()
duplicates = IntListOverrideField()

But when I look at an object in the admin, candidate_id is populated with _id["$oid"], when it should be populated with the "id" field's value.

So I am assuming somewhere the db_column "id" is being mapped to "_id"; is that correct? And is there a way to prevent that from happening?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant