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
f8f07de1
Unverified
Commit
f8f07de1
authored
8 years ago
by
Ashish Negi
Browse files
Options
Downloads
Patches
Plain Diff
Add failing test for non-indexed query. Fixes #610
parent
e19b90df
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
posting/index.go
+4
-0
4 additions, 0 deletions
posting/index.go
query/common_test.go
+15
-7
15 additions, 7 deletions
query/common_test.go
query/query_test.go
+19
-0
19 additions, 0 deletions
query/query_test.go
with
38 additions
and
7 deletions
posting/index.go
+
4
−
0
View file @
f8f07de1
...
@@ -46,6 +46,10 @@ func IndexTokens(attr string, src types.Val) ([]string, error) {
...
@@ -46,6 +46,10 @@ func IndexTokens(attr string, src types.Val) ([]string, error) {
if
err
!=
nil
||
!
schemaType
.
IsScalar
()
{
if
err
!=
nil
||
!
schemaType
.
IsScalar
()
{
return
nil
,
x
.
Errorf
(
"Cannot index attribute %s of type object."
,
attr
)
return
nil
,
x
.
Errorf
(
"Cannot index attribute %s of type object."
,
attr
)
}
}
if
!
schema
.
State
()
.
IsIndexed
(
attr
)
{
return
nil
,
x
.
Errorf
(
"Attribute %s is not indexed."
,
attr
)
}
s
:=
schemaType
s
:=
schemaType
sv
,
err
:=
types
.
Convert
(
src
,
s
)
sv
,
err
:=
types
.
Convert
(
src
,
s
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
query/common_test.go
+
15
−
7
View file @
f8f07de1
...
@@ -151,18 +151,26 @@ func addGeoData(t *testing.T, ps *store.Store, uid uint64, p geom.T, name string
...
@@ -151,18 +151,26 @@ func addGeoData(t *testing.T, ps *store.Store, uid uint64, p geom.T, name string
addEdgeToTypedValue
(
t
,
"name"
,
uid
,
types
.
StringID
,
[]
byte
(
name
),
nil
)
addEdgeToTypedValue
(
t
,
"name"
,
uid
,
types
.
StringID
,
[]
byte
(
name
),
nil
)
}
}
func
processToFastJ
SON
(
t
*
testing
.
T
,
query
string
)
string
{
func
processToFastJ
sonReq
(
t
*
testing
.
T
,
query
string
)
(
string
,
error
)
{
res
,
err
:=
gql
.
Parse
(
query
)
res
,
err
:=
gql
.
Parse
(
query
)
require
.
NoError
(
t
,
err
)
if
err
!=
nil
{
return
""
,
err
}
var
l
Latency
var
l
Latency
ctx
:=
context
.
Background
()
ctx
:=
context
.
Background
()
sgl
,
err
:=
ProcessQuery
(
ctx
,
res
,
&
l
)
sgl
,
err
:=
ProcessQuery
(
ctx
,
res
,
&
l
)
require
.
NoError
(
t
,
err
)
if
err
!=
nil
{
return
""
,
err
}
var
buf
bytes
.
Buffer
var
buf
bytes
.
Buffer
require
.
NoError
(
t
,
ToJson
(
&
l
,
sgl
,
&
buf
,
nil
))
err
=
ToJson
(
&
l
,
sgl
,
&
buf
,
nil
)
return
string
(
buf
.
Bytes
())
return
string
(
buf
.
Bytes
()),
err
}
func
processToFastJSON
(
t
*
testing
.
T
,
query
string
)
string
{
res
,
err
:=
processToFastJsonReq
(
t
,
query
)
require
.
NoError
(
t
,
err
)
return
res
}
}
func
processToPB
(
t
*
testing
.
T
,
query
string
,
debug
bool
)
*
graph
.
Node
{
func
processToPB
(
t
*
testing
.
T
,
query
string
,
debug
bool
)
*
graph
.
Node
{
...
...
This diff is collapsed.
Click to expand it.
query/query_test.go
+
19
−
0
View file @
f8f07de1
...
@@ -241,6 +241,7 @@ func TestGetUID(t *testing.T) {
...
@@ -241,6 +241,7 @@ func TestGetUID(t *testing.T) {
`{"me":[{"_uid_":"0x1","alive":true,"friend":[{"_uid_":"0x17","name":"Rick Grimes"},{"_uid_":"0x18","name":"Glenn Rhee"},{"_uid_":"0x19","name":"Daryl Dixon"},{"_uid_":"0x1f","name":"Andrea"},{"_uid_":"0x65"}],"gender":"female","name":"Michonne"}]}`
,
`{"me":[{"_uid_":"0x1","alive":true,"friend":[{"_uid_":"0x17","name":"Rick Grimes"},{"_uid_":"0x18","name":"Glenn Rhee"},{"_uid_":"0x19","name":"Daryl Dixon"},{"_uid_":"0x1f","name":"Andrea"},{"_uid_":"0x65"}],"gender":"female","name":"Michonne"}]}`
,
js
)
js
)
}
}
func
TestReturnUids
(
t
*
testing
.
T
)
{
func
TestReturnUids
(
t
*
testing
.
T
)
{
populateGraph
(
t
)
populateGraph
(
t
)
query
:=
`
query
:=
`
...
@@ -3531,3 +3532,21 @@ func TestMain(m *testing.M) {
...
@@ -3531,3 +3532,21 @@ func TestMain(m *testing.M) {
os
.
Exit
(
m
.
Run
())
os
.
Exit
(
m
.
Run
())
}
}
func
TestFilterNonIndexedPredicateFail
(
t
*
testing
.
T
)
{
populateGraph
(
t
)
// filtering on non indexing predicate fails
query
:=
`
{
me(id:0x01) {
friend @filter(leq(age, 30)) {
_uid_
name
age
}
}
}
`
_
,
err
:=
processToFastJsonReq
(
t
,
query
)
require
.
Error
(
t
,
err
)
}
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