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
f2e21988
Commit
f2e21988
authored
4 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
API: Use BadQueryErrors in datatype.py
parent
cbbc561e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caosdb/common/datatype.py
+5
-7
5 additions, 7 deletions
src/caosdb/common/datatype.py
with
5 additions
and
7 deletions
src/caosdb/common/datatype.py
+
5
−
7
View file @
f2e21988
...
...
@@ -25,8 +25,7 @@
import
re
from
..exceptions
import
(
AmbiguityException
,
EntityDoesNotExistError
,
TransactionError
)
from
..exceptions
import
EmptyUniqueQueryError
,
QueryNotUniqueError
DOUBLE
=
"
DOUBLE
"
REFERENCE
=
"
REFERENCE
"
...
...
@@ -92,9 +91,9 @@ def get_id_of_datatype(datatype):
Raises
------
AmbiguityException
QueryNotUniqueError
If there are more than one entities with the same name as the datatype.
E
ntityDoesNotExist
Error
E
mptyUniqueQuery
Error
If there is no entity with the name of the datatype.
"""
from
caosdb
import
execute_query
...
...
@@ -108,12 +107,11 @@ def get_id_of_datatype(datatype):
res
=
[
el
for
el
in
res
if
el
.
name
.
lower
()
==
datatype
.
lower
()]
if
len
(
res
)
>
1
:
raise
AmbiguityException
(
raise
QueryNotUniqueError
(
"
Name {} did not lead to unique result; Missing
"
"
implementation
"
.
format
(
datatype
))
elif
len
(
res
)
!=
1
:
ee
=
EntityDoesNotExist
Error
(
raise
EmptyUniqueQuery
Error
(
"
No RecordType named {}
"
.
format
(
datatype
))
raise
TransactionError
(
ee
)
return
res
[
0
].
id
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