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

Change the implement of the compare operator of DateTime #1895

Merged
merged 2 commits into from
Oct 13, 2021

Conversation

iamSmallY
Copy link
Contributor

@iamSmallY iamSmallY commented Aug 29, 2021

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • Component style update
  • Bundle size optimization
  • Performance optimization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

close #1894

💡 Background and solution

The way of remove millisecond in #1864 is not supported by Pomelo.EntityFrameworkCore.MySql (maybe even more third party orm libraries), so I changed the implement of compare operator.

📝 Changelog

Language Changelog
🇺🇸 English fix the bug that the code of remove millisecond in #1864 is not supported by third party orm library.
🇨🇳 Chinese 修复了#1864 中移除毫秒语句不被第三方 orm 库支持的 bug.

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Changelog is provided or not needed

@github-actions
Copy link

github-actions bot commented Aug 29, 2021

@codecov
Copy link

codecov bot commented Aug 29, 2021

Codecov Report

Merging #1895 (4e59b47) into master (62231ef) will increase coverage by 1.88%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1895      +/-   ##
==========================================
+ Coverage   25.51%   27.39%   +1.88%     
==========================================
  Files         488      511      +23     
  Lines       32187    24538    -7649     
  Branches        0      238     +238     
==========================================
- Hits         8212     6723    -1489     
+ Misses      23975    17779    -6196     
- Partials        0       36      +36     
Impacted Files Coverage Δ
...nts/table/FilterExpression/DateFilterExpression.cs 0.00% <0.00%> (ø)
components/core/Helpers/MemberPath/PathNode.cs 46.15% <0.00%> (-8.85%) ⬇️
components/core/Reflection/TypeDefined.cs 77.77% <0.00%> (-7.94%) ⬇️
components/input/InputGroup.razor.cs 87.50% <0.00%> (-6.95%) ⬇️
components/tabs/TabPane.razor 86.66% <0.00%> (-6.20%) ⬇️
...ponents/date-picker/types/DatePickerPlaceholder.cs 22.72% <0.00%> (-4.20%) ⬇️
components/input/TextArea.razor.cs 77.52% <0.00%> (-3.05%) ⬇️
...ponents/core/Component/Overlay/type/TriggerType.cs 81.25% <0.00%> (-2.97%) ⬇️
components/core/Base/AntComponentBase.cs 46.42% <0.00%> (-2.96%) ⬇️
components/timeline/Timeline.razor.cs 63.21% <0.00%> (-2.24%) ⬇️
... and 422 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 62231ef...4e59b47. Read the comment docs.

@anranruye
Copy link
Member

AddMilliseconds method can be translated by ef core, you can use this.

@iamSmallY
Copy link
Contributor Author

I've tried, but it can't be translated by Pomelo.EntityFrameworkCore.MySql which I'm currently using.

I am not sure if we should be compatible with it

@anranruye
Copy link
Member

I have tried sql server and sqlite provider and this works. It's not a good news that 'Pomelo.EntityFrameworkCore.MySql' doesn't support this translation. Can you share your usage of 'AddMilliseconds'? And there are multiple mysql providers. Maybe you can also have a try with 'MySql.EntityFrameworkCore'

@iamSmallY
Copy link
Contributor Author

My usage is

s = _db.s.Where(x => x.DateTime.AddMilliseconds(-x.DateTime.Millisecond) == DateTime.Now)

and the error is

The error was: The LINQ expression 'DbSet<x>()
    .Where(s => s.DateTime.AddMilliseconds((double)-s.DateTime.Millisecond
    ) == DateTime.Now)' could not be translated. Additional information: Translation of method 'System.DateTime.AddMilliseconds' failed.

@iamSmallY
Copy link
Contributor Author

Since PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#1497 is merged, the new implement won't cause error with Pomelo.EntityFrameworkCore.MySql

@ElderJames
Copy link
Member

Nevertheless, we need to be compatible with the older version.

@anranruye
Copy link
Member

现在 Pomelo.EntityFrameworkCore.MySql 那边属于是合并了但是没发版吧,我觉得只要那边发版了就行,兼容旧版本只能说尽量吧,但是现在不排除其他数据库/orm还有兼容问题。

@ElderJames ElderJames merged commit 572f7f9 into ant-design-blazor:master Oct 13, 2021
ElderJames added a commit that referenced this pull request Oct 16, 2021
Co-authored-by: James Yeung <shunjiey@hotmail.com>
ElderJames added a commit that referenced this pull request Apr 23, 2022
Co-authored-by: James Yeung <shunjiey@hotmail.com>
ElderJames added a commit that referenced this pull request Apr 30, 2022
Co-authored-by: James Yeung <shunjiey@hotmail.com>
ElderJames added a commit that referenced this pull request Sep 6, 2022
Co-authored-by: James Yeung <shunjiey@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The default DateTime filter in Table conflicts with some third party library
3 participants