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

[11.x] feature/add_coalesce_function #51977

Closed
wants to merge 1 commit into from
Closed

Conversation

rmunate
Copy link
Contributor

@rmunate rmunate commented Jul 1, 2024

Hello devs,

I propose adding the COALESCE function to Laravel, which would be an excellent addition. COALESCE is a standard SQL tool widely used across different databases like Oracle, MySQL, and others. By integrating it into Laravel, it helps maintain clean and understandable code for developers familiar with standard SQL. Adding COALESCE to Laravel would enhance the development experience by adhering to recognized standards and simplifying the handling of null data in our queries.

$value = coalesce($var1, $var2, $var3, ....);

@henzeb
Copy link
Contributor

henzeb commented Jul 1, 2024

Interesting, I suggest support for callbacks using value() helper.

@PerryvanderMeer
Copy link
Contributor

PerryvanderMeer commented Jul 1, 2024

What are the benefits of this above $var1 ?? $var2 ?? $var3?

@rmunate
Copy link
Contributor Author

rmunate commented Jul 1, 2024

What are the benefits of this above $var1 ?? $var2 ?? $var3?

Hi Perry,

I hope you're doing well. Regarding your question, it primarily comes down to readability and the use of standard concepts. Just as we use standard terms in SQL, applying the same naming conventions and understanding their usage fosters standardization. Similarly, the ?? operator is perfectly fine for achieving an equivalent result.

@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If applicable, please consider releasing your code as a package so that the community can still take advantage of your contributions!

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.

4 participants