Skip to content
Snippets Groups Projects
Commit 0925da46 authored by Henrik tom Wörden's avatar Henrik tom Wörden Committed by Florian Spreckelsen
Browse files

FIX: query was inaccurate

parent a929250f
No related branches found
No related tags found
1 merge request!22Release 0.3
......@@ -43,7 +43,7 @@ import warnings
from abc import ABCMeta, abstractmethod
import caosdb as db
from caosdb.exceptions import EntityDoesNotExistError
from caosdb.exceptions import AmbiguityException, EntityDoesNotExistError
from .datamodel_problems import DataModelProblems
from .guard import global_guard as guard
......@@ -83,9 +83,10 @@ def get_property(name):
if name not in PROPERTIES:
try:
prop = db.execute_query("FIND Property "+name,
prop = db.execute_query("FIND Property with name='{}'".format(
name),
unique=True)
except EntityDoesNotExistError as e:
except (EntityDoesNotExistError, AmbiguityException):
# Property might actually be a RecordTypes
prop = get_recordtype(name)
PROPERTIES[name] = prop
......@@ -102,7 +103,8 @@ def get_record(name):
"""
if name not in RECORDS:
rec = db.execute_query("FIND Record "+name, unique=True)
rec = db.execute_query("FIND Record with name='{}'".format(name),
unique=True)
RECORDS[name] = rec
return RECORDS[name]
......@@ -120,8 +122,9 @@ def get_recordtype(name):
if name not in RECORDTYPES:
try:
rec = db.execute_query("FIND RecordType "+name, unique=True)
except EntityDoesNotExistError as e:
rec = db.execute_query("FIND RecordType WITH name='{}'".format(name),
unique=True)
except (EntityDoesNotExistError, AmbiguityException) as e:
DataModelProblems.add(name)
raise e
RECORDTYPES[name] = rec
......
......@@ -76,7 +76,10 @@ class ReferencesBaseTest(unittest.TestCase):
location=None)
self.assertEqual(len(files), 1)
self.assertEqual(files[0].path, "/some/path/test.npy")
self.assertEqual(self.get_log(), "")
log = self.get_log()
assert "FIND file which" in log
assert "does not allow a search" not in log
assert "does not reference any " not in log
class ReferencesFailTest(ReferencesBaseTest):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment