Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dgraph
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
dgraph
Commits
d1c6732d
Unverified
Commit
d1c6732d
authored
8 years ago
by
Manish R Jain
Browse files
Options
Downloads
Patches
Plain Diff
Fix a bug which causes us to return no results in JSON
parent
30dc9371
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
query/query.go
+12
-8
12 additions, 8 deletions
query/query.go
query/query_test.go
+5
-2
5 additions, 2 deletions
query/query_test.go
with
17 additions
and
10 deletions
query/query.go
+
12
−
8
View file @
d1c6732d
...
...
@@ -247,15 +247,19 @@ func (g *SubGraph) ToJson(l *Latency) (js []byte, rerr error) {
log
.
Fatal
(
"We don't currently support more than 1 uid at root."
)
}
ival
:=
r
[
0
]
var
m
map
[
string
]
interface
{}
if
ival
!=
nil
{
m
=
ival
.
(
map
[
string
]
interface
{})
}
else
{
m
=
make
(
map
[
string
]
interface
{})
// r is a map, and we don't know it's key. So iterate over it, even though it only has 1 result.
for
_
,
ival
:=
range
r
{
var
m
map
[
string
]
interface
{}
if
ival
!=
nil
{
m
=
ival
.
(
map
[
string
]
interface
{})
}
else
{
m
=
make
(
map
[
string
]
interface
{})
}
m
[
"server_latency"
]
=
l
.
ToMap
()
return
json
.
Marshal
(
m
)
}
m
[
"server_latency"
]
=
l
.
ToMap
(
)
return
json
.
Marshal
(
m
)
log
.
Fatal
(
"Runtime should never reach here."
)
return
[]
byte
(
""
),
fmt
.
Errorf
(
"Runtime should never reach here."
)
}
// This function performs a binary search on the uids slice and returns the
...
...
This diff is collapsed.
Click to expand it.
query/query_test.go
+
5
−
2
View file @
d1c6732d
...
...
@@ -19,9 +19,9 @@ package query
import
(
"bytes"
"encoding/gob"
"fmt"
"io/ioutil"
"os"
"strings"
"testing"
"time"
...
...
@@ -324,7 +324,10 @@ func TestToJson(t *testing.T) {
if
err
!=
nil
{
t
.
Error
(
err
)
}
fmt
.
Printf
(
string
(
js
))
s
:=
string
(
js
)
if
!
strings
.
Contains
(
s
,
"Michonne"
)
{
t
.
Errorf
(
"Unable to find Michonne in this result: %v"
,
s
)
}
}
func
getProperty
(
properties
[]
*
graph
.
Property
,
prop
string
)
[]
byte
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment