-
Notifications
You must be signed in to change notification settings - Fork 49
Add ability to use environment variables with no database name in the url #60
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
Conversation
| db_config['TEST'] = db_config.get('TEST', {}) | ||
| db_config['SHARD_GROUP'] = shard_group | ||
|
|
||
| if not db_config['NAME'] and database_name is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also override the existing value of db_config['NAME'] even if it is set by replacing this with:
if database_name is not None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm I agree that if there's a precedence it should be the name you set, rather than the one in the URL.
|
What happens if you don't have a name in the args or the URL? |
2 similar comments
|
@JBKahn same as what would happen now if it's not in the URL: it wouldn't be set I didn't want to change the existing behaviour which doesn't validate the URL (other than using dj-database-url) |
JBKahn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll release it this weekend and update the changelog and all that.
Allows for the use of database URL environment variables with no database name specified. This will in turn result in less environment variables needed to be set when there are many shards per database node.
For example imagine an app with 1 primary database and 8 shards distributed over 3 database servers: