Skip to content
Snippets Groups Projects
Commit 7f0153d5 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

MAINT: quote name and cache query

parent 6fd897f7
Branches
Tags
1 merge request!160STY: styling
Pipeline #47056 passed
...@@ -27,8 +27,8 @@ from __future__ import annotations ...@@ -27,8 +27,8 @@ from __future__ import annotations
import logging import logging
from abc import ABCMeta, abstractmethod from abc import ABCMeta, abstractmethod
from functools import lru_cache
from datetime import datetime from datetime import datetime
from functools import lru_cache
from typing import Any from typing import Any
import caosdb as db import caosdb as db
...@@ -44,7 +44,7 @@ logger = logging.getLogger(__name__) ...@@ -44,7 +44,7 @@ logger = logging.getLogger(__name__)
def get_children_of_rt(rtname): def get_children_of_rt(rtname):
"""Supply the name of a recordtype. This name and the name of all children RTs are returned in """Supply the name of a recordtype. This name and the name of all children RTs are returned in
a list""" a list"""
return [p.name for p in cached_query(f"FIND RECORDTYPE {rtname}")] return [p.name for p in cached_query(f"FIND RECORDTYPE '{rtname}'")]
def convert_value(value: Any): def convert_value(value: Any):
...@@ -477,8 +477,7 @@ class CaosDBIdentifiableAdapter(IdentifiableAdapter): ...@@ -477,8 +477,7 @@ class CaosDBIdentifiableAdapter(IdentifiableAdapter):
return cached_get_entity_by(path=identifiable) return cached_get_entity_by(path=identifiable)
if identifiable.path is None: if identifiable.path is None:
raise RuntimeError("Path must not be None for File retrieval.") raise RuntimeError("Path must not be None for File retrieval.")
candidates = db.execute_query("FIND File which is stored at '{}'".format( candidates = cached_get_entity_by(path=identifiable.path)
identifiable.path))
if len(candidates) > 1: if len(candidates) > 1:
raise RuntimeError("Identifiable was not defined unambigiously.") raise RuntimeError("Identifiable was not defined unambigiously.")
if len(candidates) == 0: if len(candidates) == 0:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment