Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

SQLite: Translate more Math members #18843

Closed
Tracked by #22950
bricelam opened this issue Nov 11, 2019 · 4 comments · Fixed by #31356
Closed
Tracked by #22950

SQLite: Translate more Math members #18843

bricelam opened this issue Nov 11, 2019 · 4 comments · Fixed by #31356
Assignees
Labels
area-query area-sqlite breaking-change closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Milestone

Comments

@bricelam
Copy link
Contributor

bricelam commented Nov 11, 2019

SpatiaLite includes functions that could be used to enable additional translations for Math.

@bricelam
Copy link
Contributor Author

bricelam commented May 4, 2021

Additional math functions were added to SQLite 3.35.0, but need to be explicitly enabled at compile time. (ericsink/SQLitePCL.raw#416)

@bricelam
Copy link
Contributor Author

bricelam commented May 3, 2023

.NET SQL
d1 % d2 mod($d1, $d2)
EF.Functions.ToDegrees(x) (see #30926) degrees($x)
EF.Functions.ToRadians(x) radians($x)
Math.Acos(x) acos($x)
Math.Acosh(x) acosh($x)
Math.Asin(x) asin($x)
Math.Asinh(x) asinh($x)
Math.Atan(x) atan($x)
Math.Atan2(x, y) atan2($x, $y)
Math.Atanh(x) atanh($x)
Math.Ceiling(x) ceiling($x)
Math.Cos(x) cos($x)
Math.Cosh(x) cosh($x)
Math.Exp(x) exp($x)
Math.Floor(x) floor($x)
Math.Log(x, y) log($y, $x)
Math.Log(x) ln($x)
Math.Log2(x) log2($x)
Math.Log10(x) log10($x)
Math.PI (see #25049) pi($x)
Math.Pow(x, y) pow($x, $y)
Math.Sign(x) sign($x)
Math.Sin(x) sin($x)
Math.Sinh(x) sinh($x)
Math.Sqrt(x) sqrt($x)
Math.Tan(x) tan($x)
Math.Tanh(x) tanh($x)
Math.Truncate(x) trunc($x)
MathF.Acos(x) acos($x)
MathF.Acosh(x) acosh($x)
MathF.Asin(x) asin($x)
MathF.Asinh(x) asinh($x)
MathF.Atan(x) atan($x)
MathF.Atan2(x, y) atan2($x, $y)
MathF.Atanh(x) atanh($x)
MathF.Ceiling(x) ceiling($x)
MathF.Cos(x) cos($x)
MathF.Cosh(x) cosh($x)
MathF.Exp(x) exp($x)
MathF.Floor(x) floor($x)
MathF.Log(x, y) log($y, $x)
MathF.Log(x) ln($x)
MathF.Log2(x) log2($x)
MathF.Log10(x) log10($x)
MathF.PI pi($x)
MathF.Pow(x, y) pow($x, $y)
MathF.Sign(x) sign($x)
MathF.Sin(x) sin($x)
MathF.Sinh(x) sinh($x)
MathF.Sqrt(x) sqrt($x)
MathF.Tan(x) tan($x)
MathF.Tanh(x) tanh($x)
MathF.Truncate(x) trunc($x)

@bricelam bricelam changed the title SQLite: UseSpatiaLite can translate more Math members SQLite: Translate more Math members May 3, 2023
bricelam added a commit to bricelam/efcore that referenced this issue May 18, 2023
@bricelam bricelam added blocked and removed good first issue This issue should be relatively straightforward to fix. labels May 18, 2023
@bricelam
Copy link
Contributor Author

The work for this is done in bricelam:math. We're just waiting for it to be enabled in the native library now.

@bricelam
Copy link
Contributor Author

There's going to be a small breaking change here when using a version of SQLite without SQLITE_ENABLE_MATH_FUNCTIONS. Calls to Math methods in the top-level projection will now be translated to SQL causing no such function errors.

Workarounds:

  • Use a version of SQLite with SQLITE_ENABLE_MATH_FUNCTIONS
  • Define the functions yourself: connection.CreateFunction<double, double>("sin", Math.Sin)
  • Force client-eval by adding AsEnumerable to your query

@bricelam bricelam removed their assignment Jul 8, 2023
@bricelam bricelam added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Jul 25, 2023
bricelam added a commit to bricelam/efcore that referenced this issue Jul 25, 2023
@bricelam bricelam self-assigned this Jul 27, 2023
bricelam added a commit to bricelam/efcore that referenced this issue Aug 9, 2023
bricelam added a commit to bricelam/efcore that referenced this issue Aug 10, 2023
@bricelam bricelam removed the blocked label Aug 10, 2023
@bricelam bricelam modified the milestones: Backlog, 8.0.0-rc1 Aug 10, 2023
@ajcvickers ajcvickers modified the milestones: 8.0.0-rc1, 8.0.0 Nov 14, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
area-query area-sqlite breaking-change closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants