Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Better document SQL Server settings in config/database.php #9459

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

Closed
wants to merge 3 commits into from

Conversation

HenkPoley
Copy link

No description provided.

@HenkPoley
Copy link
Author

Wanted to better document how to enable MultiSubnetFailover, this 'missing' option had caused some confusion on my side.

And added the rest of the options just in case.

@taylorotwell
Copy link
Member

Can we instead just give an example of how setting any configuration option you want using DATABASE_URL? I think that is more practical. Then we can remove all of the array based configuration stuff here and link out to Microsoft documentation for all available DATABASE_URL options.

@taylorotwell
Copy link
Member

Please mark as ready for review when it's ready for me to take a look again.

@taylorotwell taylorotwell marked this pull request as draft March 7, 2024 17:58
Removed all the (deprecated?) array documentation.

Merely reference Microsoft documentation.
@HenkPoley
Copy link
Author

HenkPoley commented Mar 8, 2024

I've slashed the documentation as requested. Is the array syntax deprecated?


🤔 I did find a bug in \Illuminate\Support\ConfigurationUrlParser->getDatabase()

https://github.com/laravel/framework/blob/6c27ca43dbcfd232813ca5aba8ad3c80405ba9b1/src/Illuminate/Support/ConfigurationUrlParser.php#L96..L101

    /**
     * Get the database name from the URL.
     *
     * @param  array  $url
     * @return string|null
     */
    protected function getDatabase($url)
    {
        $path = $url['path'] ?? null;

        return $path && $path !== '/' ? substr($path, 1) : null;
    }

It receives an $url['path'] array item like Server=your_server_address;Database=your_database_name

But substr($path, 1) is of course not the way to extract the name your_database_name. But it ends up just chopping of the first letter 'S' as erver=your_server_address;Database=your_database_name (or whatever other ordering you had in the connection string.

This should be more appropriate:

    /**
     * Get the database name from the URL.
     *
     * @param array $url
     * @return string|null
     */
    protected function getDatabase($url)
    {
        $path = $url['path'] ?? null;

        $pairs = explode(';', $path);

        $databaseName = null;

        // Iterate over each pair
        foreach ($pairs as $pair) {
            // Split the pair into key and value
            list($key, $value) = explode('=', $pair, 2); // Limit to 2 elements to ensure it splits only on the first '='

            // Check if the key matches 'Database', case-insensitively
            if (strcasecmp($key, 'Database') === 0) {
                $databaseName = $value;
                break; // Stop the loop once we've found the database name
            }
        }

        return $databaseName;
    }

I'll submit patches on laravel/framework.

@HenkPoley
Copy link
Author

Until something is fixed in the handling of DATABASE_URL (for sqlsrv ?) please don't merge my most recent documentation update, the previous revision is fine though.

@driesvints driesvints closed this Mar 12, 2024
@driesvints
Copy link
Member

Hi there. We'd released v11 now. Please re-send this to 11.x if you still want to get this in. Thanks.

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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.