Skip to content

Commit

Permalink
Fix timezone in path (#258)
Browse files Browse the repository at this point in the history
* Fix timezone in path

* Fix typo

---------

Co-authored-by: Sophie <84560950+Sophie-Xie@users.noreply.github.com>
  • Loading branch information
Aiee and Sophie-Xie committed Mar 3, 2023
1 parent 9d7c5fb commit b304ce0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
28 changes: 28 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,34 @@ func TestServiceDataIO(t *testing.T) {
assert.Equal(t, expected, *localTime)
}

// Test path
{
resp, err := tryToExecute(session, "MATCH p = (:person{name: \"Bob\"}) -[e:friend]-> (:person{name: \"Lily\"}) RETURN p")
if err != nil {
t.Fatalf(err.Error())
return
}
assert.Equal(t, 1, resp.GetRowSize())
record, err := resp.GetRowValuesByIndex(0)
if err != nil {
t.Fatalf(err.Error())
return
}
valWrap, err := record.GetValueByIndex(0)
if err != nil {
t.Fatalf(err.Error())
return
}
path, err := valWrap.AsPath()
if err != nil {
t.Fatalf(err.Error())
return
}
assert.Equal(t,
"<(\"Bob\" :student{interval: P1MT100.000020000S, name: \"Bob\"} :person{age: 10, birthday: 2010-09-10T10:08:02.000000, book_num: 100, child_name: \"Hello Worl\", expend: 100.0, first_out_city: 1111, friends: 10, grade: 3, hobby: __NULL__, is_girl: false, morning: 07:10:00.000000, name: \"Bob\", property: 1000.0, start_school: 2017-09-10})-[:friend@0 {end_Datetime: 2010-09-10T10:08:02.000000, start_Datetime: 2008-09-10T10:08:02.000000}]->(\"Lily\" :student{interval: P12MT0.000000000S, name: \"Lily\"} :person{age: 9, birthday: 2010-09-10T10:08:02.000000, book_num: 100, child_name: \"Hello Worl\", expend: 100.0, first_out_city: 1111, friends: 10, grade: 3, hobby: __NULL__, is_girl: false, morning: 07:10:00.000000, name: \"Lily\", property: 1000.0, start_school: 2017-09-10})>",
path.String())
}

// Check timestamp
{
// test show jobs
Expand Down
7 changes: 4 additions & 3 deletions result_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ func genPathWrapper(path *nebula.Path, timezoneInfo timezoneInfo) (*PathWrapper,
nodeList: nodeList,
relationshipList: relationshipList,
segments: segList,
timezoneInfo: timezoneInfo,
}, nil
}

Expand Down Expand Up @@ -460,7 +461,7 @@ func (node Node) Properties(tagName string) (map[string]*ValueWrapper, error) {
kvMap := make(map[string]*ValueWrapper)
// Check if label exists
if !node.HasTag(tagName) {
return nil, fmt.Errorf("failed to get properties: Tag name %s does not exsist in the Node", tagName)
return nil, fmt.Errorf("failed to get properties: Tag name %s does not exist in the Node", tagName)
}
index := node.tagNameIndexMap[tagName]
for k, v := range node.vertex.Tags[index].Props {
Expand All @@ -472,7 +473,7 @@ func (node Node) Properties(tagName string) (map[string]*ValueWrapper, error) {
// Keys returns all prop names of the given tag name
func (node Node) Keys(tagName string) ([]string, error) {
if !node.HasTag(tagName) {
return nil, fmt.Errorf("failed to get properties: Tag name %s does not exsist in the Node", tagName)
return nil, fmt.Errorf("failed to get properties: Tag name %s does not exist in the Node", tagName)
}
var propNameList []string
index := node.tagNameIndexMap[tagName]
Expand All @@ -485,7 +486,7 @@ func (node Node) Keys(tagName string) ([]string, error) {
// Values returns all prop values of the given tag name
func (node Node) Values(tagName string) ([]*ValueWrapper, error) {
if !node.HasTag(tagName) {
return nil, fmt.Errorf("failed to get properties: Tag name %s does not exsist in the Node", tagName)
return nil, fmt.Errorf("failed to get properties: Tag name %s does not exist in the Node", tagName)
}
var propValList []*ValueWrapper
index := node.tagNameIndexMap[tagName]
Expand Down
2 changes: 1 addition & 1 deletion value_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func (valWrap ValueWrapper) GetType() string {
//
// Maps in the output will be sorted by key value in alphabetical order.
//
// For vetex, the output is in form (vid: tagName{propKey: propVal, propKey2, propVal2}),
// For vertex, the output is in form (vid: tagName{propKey: propVal, propKey2, propVal2}),
// For edge, the output is in form (SrcVid)-[name]->(DstVid)@Ranking{prop1: val1, prop2: val2}
// where arrow direction depends on edgeType.
// For path, the output is in form (v1)-[name@edgeRanking]->(v2)-[name@edgeRanking]->(v3)
Expand Down

0 comments on commit b304ce0

Please sign in to comment.