Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-pylib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
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
Code review analytics
Issue analytics
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
caosdb
Software
caosdb-pylib
Commits
3ec790f7
Unverified
Commit
3ec790f7
authored
4 years ago
by
Daniel
Browse files
Options
Downloads
Patches
Plain Diff
FIX: get_list_datatype returns correct value
parent
87896e2f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caosdb/common/datatype.py
+3
-2
3 additions, 2 deletions
src/caosdb/common/datatype.py
unittests/test_datatype.py
+30
-2
30 additions, 2 deletions
unittests/test_datatype.py
with
33 additions
and
4 deletions
src/caosdb/common/datatype.py
+
3
−
2
View file @
3ec790f7
...
...
@@ -3,7 +3,9 @@
# ** header v3.0
# This file is a part of the CaosDB Project.
#
# Copyright (C) 2020 IndiScale GmbH
# Copyright (C) 2020 Henrik tom Wörden, IndiScale GmbH
# Copyright (C) 2020 Daniel Hornung (d.hornung@indiscale.com)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
...
...
@@ -43,7 +45,7 @@ def LIST(datatype):
def
get_list_datatype
(
datatype
):
"""
returns the datatype of the elements in the list
"""
match
=
re
.
match
(
"
LIST(<|<)(?P<datatype>.*)(>|>)
"
,
"
LISTING
"
)
match
=
re
.
match
(
"
LIST(<|<)(?P<datatype>.*)(>|>)
"
,
datatype
)
if
match
is
not
None
:
return
match
.
group
(
"
datatype
"
)
...
...
@@ -65,7 +67,6 @@ def is_reference(datatype):
"""
if
datatype
in
[
DOUBLE
,
BOOLEAN
,
INTEGER
,
TEXT
,
DATETIME
]:
return
False
elif
is_list_datatype
(
datatype
):
return
is_reference
(
get_list_datatype
(
datatype
))
...
...
This diff is collapsed.
Click to expand it.
unittests/test_datatype.py
+
30
−
2
View file @
3ec790f7
from
caosdb
import
LIST
# ** header v3.0
# This file is a part of the CaosDB Project.
#
# Copyright (c) 2020 IndiScale GmbH
# Copyright (c) 2020 Daniel Hornung (d.hornung@indiscale.com)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# ** end header
import
caosdb
as
db
from
caosdb.common
import
datatype
def
test_list
():
assert
LIST
(
"
RT
"
)
==
"
LIST<RT>
"
assert
db
.
LIST
(
"
RT
"
)
==
"
LIST<RT>
"
def
test_list_utilites
():
"""
Test for example if get_list_datatype works.
"""
dtype
=
db
.
LIST
(
db
.
INTEGER
)
assert
datatype
.
get_list_datatype
(
dtype
)
==
db
.
INTEGER
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