Skip to content

Commit 93518c5

Browse files
authored
Merge pull request #24 from RedisGraph/comply_to_1.99.7_reply_format
added 1.99.7 reply format
2 parents 3430ace + 31377fc commit 93518c5

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

client_test.go

+23
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,26 @@ func TestParameterizedQuery(t *testing.T) {
272272
assert.Equal(t, res.Record().GetByIndex(0), params[index], "Unexpected parameter value")
273273
}
274274
}
275+
276+
func TestCreateIndex(t *testing.T) {
277+
res, err := graph.Query("CREATE INDEX ON :user(name)")
278+
if err != nil {
279+
t.Error(err)
280+
}
281+
assert.Equal(t, 1, res.IndicesCreated(), "Expecting 1 index created")
282+
283+
res, err = graph.Query("CREATE INDEX ON :user(name)")
284+
if err != nil {
285+
t.Error(err)
286+
}
287+
assert.Equal(t, 0, res.IndicesCreated(), "Expecting 0 index created")
288+
289+
res, err = graph.Query("DROP INDEX ON :user(name)")
290+
if err != nil {
291+
t.Error(err)
292+
}
293+
assert.Equal(t, 1, res.IndicesDeleted(), "Expecting 1 index deleted")
294+
295+
_, err = graph.Query("DROP INDEX ON :user(name)")
296+
assert.Equal(t, err.Error(), "ERR Unable to drop index on :user(name): no such index.")
297+
}

query_result.go

+10
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ const (
1717
RELATIONSHIPS_DELETED string = "Relationships deleted"
1818
PROPERTIES_SET string = "Properties set"
1919
RELATIONSHIPS_CREATED string = "Relationships created"
20+
INDICES_CREATED string = "Indices created"
21+
INDICES_DELETED string = "Indices deleted"
2022
INTERNAL_EXECUTION_TIME string = "internal execution time"
2123
)
2224

@@ -351,6 +353,14 @@ func (qr *QueryResult) RelationshipsDeleted() int {
351353
return qr.getStat(RELATIONSHIPS_DELETED)
352354
}
353355

356+
func (qr *QueryResult) IndicesCreated() int {
357+
return qr.getStat(INDICES_CREATED)
358+
}
359+
360+
func (qr *QueryResult) IndicesDeleted() int {
361+
return qr.getStat(INDICES_DELETED)
362+
}
363+
354364
func (qr *QueryResult) RunTime() int {
355365
return qr.getStat(INTERNAL_EXECUTION_TIME)
356366
}

0 commit comments

Comments
 (0)