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
expression: replace mock.Context
with StaticExprContext
in tests
#53007
base: master
Are you sure you want to change the base?
Conversation
Hi @lcwangchao. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #53007 +/- ##
================================================
+ Coverage 72.4796% 74.5399% +2.0603%
================================================
Files 1493 1493
Lines 429362 429402 +40
================================================
+ Hits 311200 320076 +8876
+ Misses 98931 89419 -9512
- Partials 19231 19907 +676
Flags with carried forward coverage won't be shown. Click here to find out more.
|
a815865
to
cb81965
Compare
/retest |
cb81965
to
e25a77d
Compare
if tp == mysql.TypeTimestamp || tp == mysql.TypeDatetime || tp == mysql.TypeDate { | ||
err = value.ConvertTimeZone(time.Local, ctx.Location()) | ||
if err != nil { | ||
return value, err | ||
} | ||
if err = value.ConvertTimeZone(defaultTime.Location(), ctx.Location()); err != nil { | ||
return value, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only file that has some logic change:
-
remove
tp == mysql.TypeTimestamp || tp == mysql.TypeDatetime || tp == mysql.TypeDate
because it seems useless. I check all the places that callgetTimeCurrentTimeStamp
. The tp is always time type. Only converting timezone for time types is also meaningless, so I removed it. -
Change the first argument of
ConvertTimeZone
fromtime.Local
todefaultTime.Location()
because this the practical meaning for this line. BecausedefaultTime
is always in local time zone if it is get from session, it is also right for previous code. But theStaticEvalContext
returns a current time with the same zone of the context, it's better to make a change.
PTAL @AilinKid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about add a intest.Assert
here?
(It's also fine to not add it, because IMO it's intuitive to call getTimeCurrentTimeStamp
with time type.
if tp == mysql.TypeTimestamp || tp == mysql.TypeDatetime || tp == mysql.TypeDate { | ||
err = value.ConvertTimeZone(time.Local, ctx.Location()) | ||
if err != nil { | ||
return value, err | ||
} | ||
if err = value.ConvertTimeZone(defaultTime.Location(), ctx.Location()); err != nil { | ||
return value, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here lgtm
7d077f7
to
b84a362
Compare
b84a362
to
aea6a28
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest LGTM
if tp == mysql.TypeTimestamp || tp == mysql.TypeDatetime || tp == mysql.TypeDate { | ||
err = value.ConvertTimeZone(time.Local, ctx.Location()) | ||
if err != nil { | ||
return value, err | ||
} | ||
if err = value.ConvertTimeZone(defaultTime.Location(), ctx.Location()); err != nil { | ||
return value, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about add a intest.Assert
here?
(It's also fine to not add it, because IMO it's intuitive to call getTimeCurrentTimeStamp
with time type.
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: YangKeao The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
What problem does this PR solve?
Issue Number: close #53006
Problem Summary:
After we introduced some static implements for
EvalContext
andExprContext
. It's better to replacemock.Context
withStaticExprContext
for the following reasons:expression
What changed and how does it work?
mock.NewContext
is replaced withmockStmtExprCtx
createContext
is replaced withmockStmtTruncateAsWarningExprCtx
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.