Skip to content

Conversation

Ricky-Hao
Copy link

If you provide db in MONGO_SETTINGS dict, and provide a host url whitch not contain database name, you would found you connect to "test" database.

I found this cause by the resolved_settings['db'] = uri_dict['database'].
This do not check if uri_dict is None.
If resolved_settings['db']=None, this code would set database name to test.

    if resolved_settings.get('db'):
        resolved_settings['name'] = resolved_settings.pop('db')
    else:
        resolved_settings['name'] = 'test'

@Ricky-Hao Ricky-Hao closed this Mar 11, 2018
@Irisha
Copy link
Contributor

Irisha commented Apr 27, 2018

@Ricky-Hao Why issue is closed?
I have had the same problem. I think this fix is necessary or documentation should be fixed by adding after this "Note that database name from uri has priority over name."
another one note "If uri presents and doesn't contain database name db setting will entirely ignore and it will set to 'test'."

Irisha added a commit to Irisha/flask-mongoengine that referenced this pull request Apr 27, 2018
Previous explanation supposed this interpretation MongoEngine#324. Since pull-request MongoEngine#324 didn't merge documentation should explain why.
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.

2 participants