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

FIX: remove superfluous AND and WITH

parent c50293da
No related branches found
No related tags found
2 merge requests!123REL: Release v0.6.0,!109FIX: remove superfluous AND and WITH
Pipeline #35112 passed
......@@ -118,6 +118,10 @@ class IdentifiableAdapter(metaclass=ABCMeta):
query_string += " AND "
query_string += IdentifiableAdapter.create_property_query(ident)
if query_string.endswith(" AND WITH "):
query_string = query_string[:-len(" AND WITH ")]
if query_string.endswith(" AND "):
query_string = query_string[:-len(" AND ")]
return query_string
@staticmethod
......
......@@ -76,6 +76,16 @@ def test_create_query_for_identifiable():
Identifiable(record_type="Person", backrefs=[], properties={'last_name': "B'Or"}))
assert query == ("FIND RECORD Person WITH 'last_name'='B\\'Or' ")
# With only backref
query = IdentifiableAdapter.create_query_for_identifiable(
Identifiable(backrefs=[160], properties={}))
assert query == ("FIND RECORD WHICH IS REFERENCED BY 160")
# With only backref and name
query = IdentifiableAdapter.create_query_for_identifiable(
Identifiable(backrefs=[160], name='lo', properties={}))
assert query == ("FIND RECORD WHICH IS REFERENCED BY 160 AND WITH name='lo'")
def test_load_from_yaml_file():
ident = CaosDBIdentifiableAdapter()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment