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

Translate to GREATEST/LEAST in relational #31681

Closed
roji opened this issue Sep 11, 2023 · 0 comments · Fixed by #32338
Closed

Translate to GREATEST/LEAST in relational #31681

roji opened this issue Sep 11, 2023 · 0 comments · Fixed by #32338
Assignees
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-enhancement

Comments

@roji
Copy link
Member

roji commented Sep 11, 2023

Most/all relational database support GREATEST/LEAST, which accept an arbitrary number of parameters and return the greatest one. Note that unlike MAX/MIN, these aren't aggregate functions - they're just regular, non-aggregate variadic functions.

Database Functions Notes
PostgreSQL GREATEST/LEAST
MySQL GREATEST/LEAST
MariaDB GREATEST/LEAST
SQLite MAX/MIN These are non-aggregate with multiple arguments
SQL Server GREATEST/LEAST SQL Server 2022 and above
Oracle GREATEST/LEAST

We can add EF.Functions.{Greatest,Least} in relational to support these. Note that these would be similar to Math.Max and Min, which we should also translate; however, a custom EF.Functions.Greatest would provide the following advantages:

  • Support types for which Math.Max overloads don't exist (DateTime, string...)
  • Allow passing more than 2 arguments without nesting Math.Max calls, since these aren't variadic and support only two arguments.

Originally requested e.g. in npgsql/efcore.pg#2866

@ajcvickers ajcvickers added this to the Backlog milestone Sep 22, 2023
@roji roji self-assigned this Nov 18, 2023
roji added a commit to roji/efcore that referenced this issue Nov 18, 2023
roji added a commit to roji/efcore that referenced this issue Nov 18, 2023
roji added a commit to roji/efcore that referenced this issue Nov 18, 2023
roji added a commit to roji/efcore that referenced this issue Nov 18, 2023
roji added a commit to roji/efcore that referenced this issue Nov 18, 2023
roji added a commit to roji/efcore that referenced this issue Nov 27, 2023
roji added a commit that referenced this issue Nov 28, 2023
@roji roji modified the milestones: Backlog, 9.0.0 Nov 28, 2023
@roji roji added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Nov 28, 2023
@ajcvickers ajcvickers modified the milestones: 9.0.0, 9.0.0-preview1 Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants