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

Mongodb SRV not supported #283

Open
tahpot opened this issue Sep 12, 2019 · 3 comments
Open

Mongodb SRV not supported #283

tahpot opened this issue Sep 12, 2019 · 3 comments
Labels
status:ready for adoption Feel free to implement this issue. type:bug Bug

Comments

@tahpot
Copy link

tahpot commented Sep 12, 2019

MongoDB supports SRV DSN format (https://www.mongodb.com/blog/post/mongodb-3-6-here-to-SRV-you-with-easier-replica-set-connections) since v3.6

In yii2-mongodb/src/Connection.php there's a regex expecting mongodb://, whereas the new format is mongodb+srv://, so this regex fails.

@tahpot tahpot changed the title Bug: Mongodb SRV not supported Mongodb SRV not supported Sep 12, 2019
@samdark samdark added status:ready for adoption Feel free to implement this issue. type:bug Bug labels Sep 12, 2019
@samdark
Copy link
Member

samdark commented Sep 12, 2019

Does it work if regex is fixed? If so, do you want to do a pull request?

@samdark samdark added this to the 2.1.8 milestone Sep 12, 2019
@samdark samdark removed this from the 2.1.8 milestone Oct 8, 2019
@ndobromirov
Copy link

@samdark it does not, as then it fails on the Native PHP driver for some reason after that...

@squio
Copy link
Contributor

squio commented May 18, 2023

This regex is only used to parse the default database name when it is not set; the work around is to simply provide a defaultDatabaseName in the configuration in config.php:

'mongodb' => [
	'class' => '\yii\mongodb\Connection',
	'dsn' => 'mongodb+srv://user:[email protected]/?retryWrites=true&w=majority',
	'defaultDatabaseName' => 'my_database',
],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready for adoption Feel free to implement this issue. type:bug Bug
Projects
None yet
Development

No branches or pull requests

4 participants