Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
David Kosztka
Pod
Commits
574a966b
Unverified
Commit
574a966b
authored
3 years ago
by
Vasili Novikov
Browse files
Options
Download
Email Patches
Plain Diff
Allow creating Edge items via the create_item API
parent
7fed938b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/internal_api.rs
+17
-8
src/internal_api.rs
src/schema.rs
+0
-7
src/schema.rs
with
17 additions
and
15 deletions
+17
-15
src/internal_api.rs
+
17
-
8
View file @
574a966b
...
...
@@ -84,14 +84,6 @@ pub fn create_item_tx(
cli
:
&
CliOptions
,
database_key
:
&
DatabaseKey
,
)
->
Result
<
String
>
{
if
schema
::
is_edge
(
&
item
._type
)
{
return
Err
(
Error
{
code
:
StatusCode
::
BAD_REQUEST
,
msg
:
"Cannot create edges via item addition API. Use create_edge or similar APIs
\
in order to also create _source, _target bindings"
.to_string
(),
});
};
let
id
:
String
=
if
let
Some
(
id
)
=
&
item
.id
{
id
.to_string
()
}
else
{
...
...
@@ -607,6 +599,23 @@ mod tests {
};
}
#[test]
/// Test creating an item that has type="Edge"
fn
test_create_edge_item
()
{
let
mut
conn
=
new_conn
();
let
cli
=
command_line_interface
::
tests
::
test_cli
();
let
db_key
=
DatabaseKey
::
from
(
""
.to_string
())
.unwrap
();
let
tx
=
conn
.transaction
()
.unwrap
();
let
mut
schema
=
database_api
::
get_schema
(
&
tx
)
.unwrap
();
let
edge_item
=
json!
({
"type"
:
"Edge"
,
});
let
edge_item
:
CreateItem
=
serde_json
::
from_value
(
edge_item
)
.unwrap
();
// Creating raw "Edge" items should be successful.
// (It is also the way how Memri clients push edge information to the Pod.)
create_item_tx
(
&
tx
,
&
mut
schema
,
edge_item
,
""
,
&
cli
,
&
db_key
)
.unwrap
();
}
#[test]
fn
test_edge_search
()
{
let
mut
conn
=
new_conn
();
...
...
This diff is collapsed.
Click to expand it.
src/schema.rs
+
0
-
7
View file @
574a966b
...
...
@@ -89,13 +89,6 @@ fn validate_property_name_syntax(property: &str) -> Result<()> {
}
}
/// Returns whether an item type is an "Edge".
/// Currently, only literally "Edge" item type is an edge. This implementation is UNSTABLE.
/// See `docs/HTTP_API.md` for details.
pub
fn
is_edge
(
item_type
:
&
str
)
->
bool
{
item_type
==
"Edge"
}
/// All item properties should be of this format
pub
fn
validate_property_name
(
property
:
&
str
)
->
Result
<
()
>
{
if
let
Err
(
err
)
=
validate_property_name_syntax
(
property
)
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets