-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Parse time literals using the time zone in the select statement #8642
Conversation
bfcbe85
to
4fdcbcd
Compare
4fdcbcd
to
1195f9d
Compare
1195f9d
to
950753d
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.
LGTM. Mostly just a couple general questions/comments.
@@ -4868,7 +4877,7 @@ func reduceBinaryExprBooleanLHS(op Token, lhs *BooleanLiteral, rhs Expr) Expr { | |||
return &BinaryExpr{Op: op, LHS: lhs, RHS: rhs} | |||
} | |||
|
|||
func reduceBinaryExprDurationLHS(op Token, lhs *DurationLiteral, rhs Expr) Expr { | |||
func reduceBinaryExprDurationLHS(op Token, lhs *DurationLiteral, rhs Expr, loc *time.Location) Expr { |
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.
Kind of sucks that this bleeds into the some of the binary expression reducing. Guess it has to though.
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.
Yea, I didn't like this. Might be improved in the future with some better parsing of the expression.
@@ -5300,9 +5309,16 @@ type Valuer interface { | |||
Value(key string) (interface{}, bool) | |||
} | |||
|
|||
// ZoneValuer is the interface that specifies the current time zone. | |||
type ZoneValuer interface { |
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.
Do we really need this interface? Seems like the only place this gets used is
+ loc := time.UTC
+ if v, ok := valuer.(ZoneValuer); ok {
+ loc = v.Zone()
+ }
Is there any anticipation that there will be anything else that implements ZoneValuer
?
I guess I've never quite understood why people use create an interface (it seems pretty common) for something where a concrete type would suffice.
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.
It's because this is an extension of the Valuer
interface and not all Valuer
s can have a Zone method.
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.
But you could just as easily casted to a NowValuer
Fixes #8639.