Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-julialib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
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
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-julialib
Commits
eb57ac6c
Commit
eb57ac6c
authored
3 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Check that only properties can have a datatype
parent
b9a530cb
No related branches found
No related tags found
1 merge request
!7
ENH: Implement queries and entity retrieval
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Entity.jl
+41
-11
41 additions, 11 deletions
src/Entity.jl
test/runtests.jl
+5
-0
5 additions, 0 deletions
test/runtests.jl
with
46 additions
and
11 deletions
src/Entity.jl
+
41
−
11
View file @
eb57ac6c
...
@@ -603,11 +603,13 @@ function get_description(message::Ref{_Message})
...
@@ -603,11 +603,13 @@ function get_description(message::Ref{_Message})
return
unsafe_string
(
out
[])
return
unsafe_string
(
out
[])
end
end
# TODO(henrik, daniel) Include Bools for list and reference here. How should they be returned to the user?
# TODO(henrik, daniel) Is this the best way to return name, is_ref,
# and is_list to the users? Should we split it up?
"""
"""
function get_datatype(entity::Ref{_Entity})
function get_datatype(entity::Ref{_Entity})
Return the datatype of the given `entity`
Return a tuple that contains the name of the datatype of the given
`entity`, whether it is a reference, and whether it is a list.
"""
"""
function
get_datatype
(
entity
::
Ref
{
_Entity
})
function
get_datatype
(
entity
::
Ref
{
_Entity
})
...
@@ -633,7 +635,8 @@ end
...
@@ -633,7 +635,8 @@ end
"""
"""
function get_datatype(entity::Ref{_Property})
function get_datatype(entity::Ref{_Property})
Return the datatype of the given `property`
Return a tuple that contains the name of the datatype of the given
`property`, whether it is a reference, and whether it is a list.
"""
"""
function
get_datatype
(
property
::
Ref
{
_Property
})
function
get_datatype
(
property
::
Ref
{
_Property
})
...
@@ -1389,14 +1392,22 @@ function set_description(entity::Ref{_Entity}, description::AbstractString)
...
@@ -1389,14 +1392,22 @@ function set_description(entity::Ref{_Entity}, description::AbstractString)
CaosDB
.
Exceptions
.
evaluate_return_code
(
err_code
)
CaosDB
.
Exceptions
.
evaluate_return_code
(
err_code
)
end
end
# TODO(henrik, daniel) Should throw an error if role != PROPERTY since
# TODO(henrik, daniel) Convenience functions for lists and references,
# it is silently ignored by C(++) otherwise. Also include bools for
# too?
# lists and references. Convenience functions for lists and
# references, too?
"""
"""
function set_datatype(entity::Ref{_Entity}, datatype::AbstractString)
function set_datatype(
entity::Ref{_Entity},
datatype::AbstractString;
is_list::Bool = false,
is_reference::Bool = false,
)
Set the datatype of the given `entity` object.
Set the datatype of the given `entity` object to the given `datatype`
name. Only possible if the role of the entity is "
PROPERTY
". Specify
whether it is a reference or a list with the optional `is_list` and
`is_reference` keyword arguments. If the datatype is not a reference,
it is checked against the Atomic Datatypes known to CaosDB and an
exception is thrown if it is not known.
"""
"""
function
set_datatype
(
function
set_datatype
(
entity
::
Ref
{
_Entity
},
entity
::
Ref
{
_Entity
},
...
@@ -1404,6 +1415,15 @@ function set_datatype(
...
@@ -1404,6 +1415,15 @@ function set_datatype(
is_list
::
Bool
=
false
,
is_list
::
Bool
=
false
,
is_reference
::
Bool
=
false
,
is_reference
::
Bool
=
false
,
)
)
if
get_role
(
entity
)
!=
"PROPERTY"
throw
(
CaosDB
.
Exceptions
.
ClientException
(
"Only entities with role PROPERTY can be assigned a datatype."
,
),
)
end
err_code
=
ccall
(
err_code
=
ccall
(
(
:
caosdb_entity_entity_set_datatype
,
CaosDB
.
library_name
),
(
:
caosdb_entity_entity_set_datatype
,
CaosDB
.
library_name
),
Cint
,
Cint
,
...
@@ -1419,9 +1439,19 @@ end
...
@@ -1419,9 +1439,19 @@ end
"""
"""
function set_datatype(property::Ref{_Property}, datatype::AbstractString)
function set_datatype(
property::Ref{_Property},
datatype::AbstractString;
is_list::Bool = false,
is_reference::Bool = false,
)
Set the datatype of the given `property` object.
Set the datatype of the given `property` object to the given
`datatype` name. Specify whether it is a reference or a list with the
optional `is_list` and `is_reference` keyword arguments. If the
datatype is not a reference, it is checked against the Atomic
Datatypes known to CaosDB and an exception is thrown if it is not
known.
"""
"""
function
set_datatype
(
function
set_datatype
(
property
::
Ref
{
_Property
},
property
::
Ref
{
_Property
},
...
...
This diff is collapsed.
Click to expand it.
test/runtests.jl
+
5
−
0
View file @
eb57ac6c
...
@@ -111,6 +111,11 @@ using CaosDB
...
@@ -111,6 +111,11 @@ using CaosDB
rec_with_parent_and_props
,
rec_with_parent_and_props
,
"some_id"
,
"some_id"
,
)
)
# cannot set the datatype of a record
@test_throws
CaosDB
.
Exceptions
.
ClientException
CaosDB
.
Entity
.
set_datatype
(
rec_with_parent_and_props
,
"INTEGER"
,
)
par1
=
CaosDB
.
Entity
.
create_parent
(
name
=
"Parent1"
)
par1
=
CaosDB
.
Entity
.
create_parent
(
name
=
"Parent1"
)
par2
=
CaosDB
.
Entity
.
create_parent
(
name
=
"Parent2"
,
id
=
"id_of_parent_2"
)
par2
=
CaosDB
.
Entity
.
create_parent
(
name
=
"Parent2"
,
id
=
"id_of_parent_2"
)
...
...
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