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

Add missing and convenient EF.Functions.DateDiff translations #1876

Conversation

lauxjpn
Copy link
Collaborator

@lauxjpn lauxjpn commented Mar 10, 2024

Adds the following translations that are directly supported by MySQL compatible databases:

  • DateDiffQuarter
  • DateDiffWeek

Add the following convenience translations:

  • DateDiffMillisecond
  • DateDiffTick
  • DateDiffNanosecond

#1875 will change the return type (at least of the second group) in the future from int to long.

Fixes #1837 (in part)

@lauxjpn lauxjpn added type-enhancement backport-candidate Should be considered for backporting. labels Mar 10, 2024
@lauxjpn lauxjpn added this to the 9.0.0-preview.2 milestone Mar 10, 2024
@lauxjpn lauxjpn self-assigned this Mar 10, 2024
@lauxjpn lauxjpn merged commit 5322b41 into PomeloFoundation:main Mar 12, 2024
19 checks passed
@lauxjpn lauxjpn deleted the feature/issue1837_add_missing_datediff_translations branch March 12, 2024 00:16
@lauxjpn
Copy link
Collaborator Author

lauxjpn commented Mar 16, 2024

(From #1875 (comment):)

All this seems to be in line with the general policy that stuff in EF.Functions corresponds directly to SQL functions (as much as possible) [...]

@roji Is there an existing/recommended pattern for adding convenience methods that the database does not implement (but we translate into working SQL anyway) and that complement methods in EF.Functions?

An example would be from the OP:

Add the following convenience translations:

  • DateDiffMillisecond
  • DateDiffTick
  • DateDiffNanosecond

@roji
Copy link

roji commented Mar 16, 2024

Hmm, I'm not sure we have such convenience methods at the moment - I'd have to look.

OTOH I'd introduce these on EF.Functions alongside methods that translate directly to database functions - I'm not sure the user should care whether something translates directly to a SQL function or to a more elaborate construct.

BTW note that an alternative to providing an EF.Functions convenience thing, is to pattern-match a more complex construct in the query tree, i.e. where we avoid introducing a special function. That may be preferable - as long as it makes sense and allows expressing the same thing without a special thing...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-candidate Should be considered for backporting. type-enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: DateDiff Function
2 participants