Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Goblin
Manage
Activity
Members
Labels
Plan
Issues
3
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Goblin OGM
Goblin
Commits
e48a4f88
Commit
e48a4f88
authored
8 years ago
by
davebshow
Browse files
Options
Downloads
Patches
Plain Diff
polishing
parent
75d18eb9
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
goblin/api.py
+6
-0
6 additions, 0 deletions
goblin/api.py
goblin/query.py
+5
-0
5 additions, 0 deletions
goblin/query.py
tests/test_engine.py
+1
-2
1 addition, 2 deletions
tests/test_engine.py
with
12 additions
and
2 deletions
goblin/api.py
+
6
−
0
View file @
e48a4f88
...
...
@@ -153,10 +153,16 @@ class Session:
await
stream
.
close
()
return
mapper_func
(
result
.
data
[
0
],
element
,
element
.
__mapping__
)
async
def
get_vertex_by_id
(
self
,
element
):
pass
def
_get_vertex_by_id
(
self
,
element
):
traversal
=
self
.
g
.
V
(
element
.
id
)
return
query
.
parse_traversal
(
traversal
)
async
def
get_edge_by_id
(
self
,
element
):
pass
def
_get_edge_by_id
(
self
,
element
):
traversal
=
self
.
g
.
E
(
element
.
id
)
return
query
.
parse_traversal
(
traversal
)
...
...
This diff is collapsed.
Click to expand it.
goblin/query.py
+
5
−
0
View file @
e48a4f88
"""
Query API and helpers
"""
from
goblin
import
mapper
def
parse_traversal
(
traversal
):
...
...
@@ -6,17 +7,21 @@ def parse_traversal(traversal):
bindings
=
traversal
.
bindings
return
script
,
bindings
class
Query
:
def
__init__
(
self
,
session
,
element_class
):
self
.
_session
=
session
self
.
_engine
=
session
.
engine
self
.
_element_class
=
element_class
if
element_class
.
__type__
==
'
vertex
'
:
self
.
_traversal
=
self
.
_session
.
g
.
V
().
hasLabel
(
element_class
.
__mapping__
.
label
)
self
.
_mapper
=
mapper
.
map_vertex_to_ogm
elif
element_class
.
__type__
==
'
edge
'
:
self
.
_traversal
=
self
.
_session
.
g
.
E
().
hasLabel
(
element_class
.
__mapping__
.
label
)
self
.
_mapper
=
mapper
.
map_edge_to_ogm
else
:
raise
Exception
(
"
unknown element type
"
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_engine.py
+
1
−
2
View file @
e48a4f88
...
...
@@ -50,12 +50,11 @@ class TestEngine(unittest.TestCase):
leif
.
name
=
'
leifur
'
jon
=
TestVertex
()
jon
.
name
=
'
jonathan
'
session
.
add
(
leif
,
jon
)
works_for
=
TestEdge
()
works_for
.
source
=
jon
works_for
.
target
=
leif
works_for
.
notes
=
'
zerofail
'
session
.
add
(
works_for
)
session
.
add
(
leif
,
jon
,
works_for
)
await
session
.
flush
()
current
=
session
.
_current
[
works_for
.
id
]
self
.
assertEqual
(
current
.
notes
,
'
zerofail
'
)
...
...
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