Skip to content

Add support of "bson.dbref.DBRef" data type for formatting value. The…#692

Open
burnettzhong wants to merge 3 commits intoyougov:masterfrom
burnettzhong:master
Open

Add support of "bson.dbref.DBRef" data type for formatting value. The…#692
burnettzhong wants to merge 3 commits intoyougov:masterfrom
burnettzhong:master

Conversation

@burnettzhong
Copy link
Copy Markdown

… "bson.dbref.DBRef" is used by Solr DBRef.

elif isinstance(value, datetime.datetime):
return value
elif isinstance(value, bson.dbref.DBRef):
return value.id
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the DBRef.database and DBRef.collection?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are correct, this change does not cover database and collection value, but only the id value.
At least, it supports DBRef data from MongoDB, and it can be used by complex search like "join" in Solr.
In order to cover database and collection value, we need to modify function transform_element and format_document which I'm working on it.

Comment thread README.rst Outdated
-----------
Add support to DBRef whose datatype is "bson.dbref.DBRef".


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove this.

@burnettzhong
Copy link
Copy Markdown
Author

burnettzhong commented Apr 3, 2017

I have updated it to cover all database, collection and id data. It works perfect in my local environment.
I am not good at Python, sorry if my code is repeating. I am very glad if someone can refine it.

@burnettzhong
Copy link
Copy Markdown
Author

BTW, have no idea why the CI is failed for MongoDB 2.4.14

@KamalHr
Copy link
Copy Markdown

KamalHr commented May 30, 2018

Does this work fine with elasticsearch?

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

Successfully merging this pull request may close these issues.

3 participants