-
Notifications
You must be signed in to change notification settings - Fork 9
Add time-related query tests and enhance query result handling for da… #34
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
7e49f57
d5d7598
0a000c3
7db0a62
8d39a9c
97b3357
649290c
e452100
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,6 +6,7 @@ import ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| "os" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "strconv" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "strings" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "time" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "github.com/olekukonko/tablewriter" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -48,6 +49,9 @@ const ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| VALUE_MAP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| VALUE_POINT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| VALUE_VECTORF32 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| VALUE_DATETIME // Deprecated, use VALUE_POINT instead | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
barakb marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| VALUE_DATETIME // Deprecated, use VALUE_POINT instead | |
| VALUE_DATETIME // Deprecated: Retained for backward compatibility. Migrate to VALUE_POINT where possible. |
Copilot
AI
Jul 9, 2025
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.
Directly asserting v.(int64) may panic if the stored value isn’t an int64. Use a safe type check (t, ok := v.(int64)) and return an error if the assertion fails.
| return time.Unix(v.(int64), 0), nil | |
| case VALUE_DATE: | |
| return time.Unix(v.(int64), 0), nil | |
| case VALUE_TIME: | |
| return time.UnixMilli(v.(int64)), nil | |
| timestamp, ok := v.(int64) | |
| if !ok { | |
| return nil, errors.New("expected int64 for VALUE_DATETIME") | |
| } | |
| return time.Unix(timestamp, 0), nil | |
| case VALUE_DATE: | |
| timestamp, ok := v.(int64) | |
| if !ok { | |
| return nil, errors.New("expected int64 for VALUE_DATE") | |
| } | |
| return time.Unix(timestamp, 0), nil | |
| case VALUE_TIME: | |
| timestamp, ok := v.(int64) | |
| if !ok { | |
| return nil, errors.New("expected int64 for VALUE_TIME") | |
| } | |
| return time.UnixMilli(timestamp), nil |
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.
Fix timezone drift: normalize temporal values to UTC.
Tests show hour mismatch for localtime; time.Unix/UnixMilli returns a Time in Local zone. Normalize to UTC to keep deterministic values across environments.
Apply:
case VALUE_DATETIME:
- return time.Unix(v.(int64), 0), nil
+ return time.Unix(v.(int64), 0).UTC(), nil
case VALUE_DATE:
- return time.Unix(v.(int64), 0), nil
+ return time.Unix(v.(int64), 0).UTC(), nil
case VALUE_TIME:
- return time.UnixMilli(v.(int64)), nil
+ return time.UnixMilli(v.(int64)).UTC(), nil📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| case VALUE_DATETIME: | |
| return time.Unix(v.(int64), 0), nil | |
| case VALUE_DATE: | |
| return time.Unix(v.(int64), 0), nil | |
| case VALUE_TIME: | |
| return time.UnixMilli(v.(int64)), nil | |
| case VALUE_DATETIME: | |
| return time.Unix(v.(int64), 0).UTC(), nil | |
| case VALUE_DATE: | |
| return time.Unix(v.(int64), 0).UTC(), nil | |
| case VALUE_TIME: | |
| return time.UnixMilli(v.(int64)).UTC(), nil |
🤖 Prompt for AI Agents
In query_result.go around lines 349 to 357, the temporal cases return time
values in the local zone causing timezone drift; update each return to normalize
to UTC by calling .UTC() on the constructed Time (e.g. time.Unix(v.(int64),
0).UTC(), and time.UnixMilli(v.(int64)).UTC()) so returned times are
deterministic across environments.
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.
Harden TestGetTime: fix assert arg order and add error/empty checks.
Current failure stems from reversed assert args and potential timezone drift. After normalizing to UTC in parser, update the test for robustness.
func TestGetTime(t *testing.T) { q := "RETURN localtime({hour: 12}) AS time" res, err := graph.Query(q, nil, nil) - if err != nil { - t.Error(err) - } - res.Next() - r := res.Record() - timeValue := r.GetByIndex(0).(time.Time) - assert.Equal(t, timeValue.Hour(), 12, "Unexpected Time value") + if err != nil { t.Fatal(err) } + if res == nil { t.Fatal("Query result is nil") } + if !res.Next() { t.Fatal("empty result") } + r := res.Record() + val := r.GetByIndex(0) + timeValue, ok := val.(time.Time) + if !ok { t.Fatalf("Expected time.Time, got %T", val) } + assert.Equal(t, 12, timeValue.Hour(), "Unexpected Time value") }📝 Committable suggestion
🧰 Tools
🪛 GitHub Actions: Go
[error] 320-320: TestGetTime failed: Not equal: expected: 10, actual: 12. Unexpected Time value. Command: go test -v ./...
🤖 Prompt for AI Agents