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

Fix DATABASE_URL parsing in ConfigurationUrlParser->getDatabase() #50420

Closed
wants to merge 1 commit into from

Conversation

HenkPoley
Copy link

Not sure how this ever worked.

Maybe it used to recieve $url['path'] => '=database_name' from DB_DATABASE=database_name in .env. So chopping off the first character ('=') would work. But that's now how it works today.

Connecting to the database without setting the DATABASE_URL, and using the array syntax from config/database.php still works.

Found in: laravel/docs#9459

@HenkPoley
Copy link
Author

Hmm, I see this breaks some database support. I guess I'll have to dig into that before this can be merged.

My current use case is for Microsoft SQL Server (sqldrv).

@driesvints
Copy link
Member

Feel free to resend this once you have passing tests 👍

@driesvints driesvints closed this Mar 8, 2024
@HenkPoley
Copy link
Author

HenkPoley commented Mar 8, 2024

The reason I'm submitting this is that \Illuminate\Database\Connectors\SqlServerConnector::buildConnectString() I'm seeing

"sqlsrv:Server=127.0.0.1,1433;Database=erver=127.0.0.1,1433;Database=database_name"

Everything at and after spurious 'erver=' part is not right, of course. I think it kind of works on some databases, because it kind of defines Database= twice.

ConfigurationUrlParser->getDatabase() is the place there 'Server=..' is converted to 'erver=..'. And I think it ought to return the database name.

I'm not very well versed with the insides of Laravel. So @driesvints, I think I will need some help in figuring it out.

Right now I don't have more time to look into it.

@HenkPoley
Copy link
Author

For reference, the above bug in \Illuminate\Support\ConfigurationUrlParser::getDatabase() is currently in laravel/framework v10.47.0

It affects both sqlsrv and mysql, when using DATABASE_URL= in .env

@HenkPoley
Copy link
Author

@mathieutu since you wrote \Illuminate\Support\ConfigurationUrlParser::getDatabase(), 5 years ago, maybe you know how to fix it?

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