diff --git a/pyvo/registry/rtcons.py b/pyvo/registry/rtcons.py index 3f04e090e..906c55927 100644 --- a/pyvo/registry/rtcons.py +++ b/pyvo/registry/rtcons.py @@ -244,7 +244,7 @@ def _get_union_condition(self, service): "SELECT ivoid FROM rr.resource WHERE" " 1=ivo_hasword(res_title, {{{parname}}})", "SELECT ivoid FROM rr.res_subject WHERE" - " res_subject ILIKE {{{parpatname}}}"] + " rr.res_subject.res_subject ILIKE {{{parpatname}}}"] self._fillers, subqueries = {}, [] for index, word in enumerate(self.words): @@ -265,7 +265,7 @@ def _get_or_condition(self, service): base_queries = [ " 1=ivo_hasword(res_description, {{{parname}}})", " 1=ivo_hasword(res_title, {{{parname}}})", - " res_subject ILIKE {{{parpatname}}}"] + " rr.res_subject.res_subject ILIKE {{{parpatname}}}"] self._fillers, conditions = {}, [] for index, word in enumerate(self.words): diff --git a/pyvo/registry/tests/test_regtap.py b/pyvo/registry/tests/test_regtap.py index 67d52ca3e..a4d9bd802 100644 --- a/pyvo/registry/tests/test_regtap.py +++ b/pyvo/registry/tests/test_regtap.py @@ -67,7 +67,7 @@ def keywordstest_callback(request, context): assert "ivo_hasword(res_description, 'vizier')" in query assert "1=ivo_hasword(res_title, 'vizier')" in query - assert " res_subject ILIKE '%pulsar%'" in query + assert ".res_subject ILIKE '%pulsar%'" in query assert "1=ivo_hasword(res_description, 'pulsar')" in query assert "1=ivo_hasword(res_title, 'pulsar')" in query @@ -86,7 +86,7 @@ def keywordstest_callback(request, context): data = dict(parse_qsl(request.body)) query = data['QUERY'] - assert "OR res_subject ILIKE '%single%'" in query + assert "OR rr.res_subject.res_subject ILIKE '%single%'" in query assert "1=ivo_hasword(res_description, 'single') " in query assert "1=ivo_hasword(res_title, 'single')" in query diff --git a/pyvo/registry/tests/test_rtcons.py b/pyvo/registry/tests/test_rtcons.py index 2b5ac14bf..a3dc61255 100644 --- a/pyvo/registry/tests/test_rtcons.py +++ b/pyvo/registry/tests/test_rtcons.py @@ -78,30 +78,30 @@ def test_basic(self): assert rtcons.Freetext("star").get_search_condition(FAKE_GAVO) == ( "ivoid IN (SELECT ivoid FROM rr.resource WHERE 1=ivo_hasword(res_description, 'star') " "UNION SELECT ivoid FROM rr.resource WHERE 1=ivo_hasword(res_title, 'star') " - "UNION SELECT ivoid FROM rr.res_subject WHERE res_subject ILIKE '%star%')") + "UNION SELECT ivoid FROM rr.res_subject WHERE rr.res_subject.res_subject ILIKE '%star%')") def test_interesting_literal(self): assert rtcons.Freetext("α Cen's planets").get_search_condition(FAKE_GAVO) == ( "ivoid IN (SELECT ivoid FROM rr.resource WHERE 1=ivo_hasword(res_description, 'α Cen''s planets')" " UNION SELECT ivoid FROM rr.resource WHERE 1=ivo_hasword(res_title, 'α Cen''s planets')" - " UNION SELECT ivoid FROM rr.res_subject WHERE res_subject ILIKE '%α Cen''s planets%')") + " UNION SELECT ivoid FROM rr.res_subject WHERE rr.res_subject.res_subject ILIKE '%α Cen''s planets%')") def test_multipleLiterals(self): assert rtcons.Freetext("term1", "term2" ).get_search_condition(FAKE_GAVO) == ( "ivoid IN (SELECT ivoid FROM rr.resource WHERE 1=ivo_hasword(res_description, 'term1')" " UNION SELECT ivoid FROM rr.resource WHERE 1=ivo_hasword(res_title, 'term1')" - " UNION SELECT ivoid FROM rr.res_subject WHERE res_subject ILIKE '%term1%')" + " UNION SELECT ivoid FROM rr.res_subject WHERE rr.res_subject.res_subject ILIKE '%term1%')" " AND " "ivoid IN (SELECT ivoid FROM rr.resource WHERE 1=ivo_hasword(res_description, 'term2')" " UNION SELECT ivoid FROM rr.resource WHERE 1=ivo_hasword(res_title, 'term2')" - " UNION SELECT ivoid FROM rr.res_subject WHERE res_subject ILIKE '%term2%')") + " UNION SELECT ivoid FROM rr.res_subject WHERE rr.res_subject.res_subject ILIKE '%term2%')") def test_adaption_to_service(self): assert rtcons.Freetext("term1", "term2" ).get_search_condition(FAKE_PLAIN) == ( - "( 1=ivo_hasword(res_description, 'term1') OR 1=ivo_hasword(res_title, 'term1') OR res_subject ILIKE '%term1%')" - " AND ( 1=ivo_hasword(res_description, 'term2') OR 1=ivo_hasword(res_title, 'term2') OR res_subject ILIKE '%term2%')") + "( 1=ivo_hasword(res_description, 'term1') OR 1=ivo_hasword(res_title, 'term1') OR rr.res_subject.res_subject ILIKE '%term1%')" + " AND ( 1=ivo_hasword(res_description, 'term2') OR 1=ivo_hasword(res_title, 'term2') OR rr.res_subject.res_subject ILIKE '%term2%')") class TestAuthorConstraint: @@ -336,7 +336,6 @@ def test_no_temporal(self): == "stc_temporal missing on current RegTAP service") - class TestWhereClauseBuilding: @staticmethod def where_clause_for(*args, **kwargs): @@ -388,11 +387,11 @@ def test_with_legacy_keyword(self): '(ivoid IN (SELECT ivoid FROM rr.resource WHERE ' "1=ivo_hasword(res_description, 'plain') UNION SELECT ivoid FROM rr.resource " "WHERE 1=ivo_hasword(res_title, 'plain') UNION SELECT ivoid FROM " - "rr.res_subject WHERE res_subject ILIKE '%plain%'))\n" + "rr.res_subject WHERE rr.res_subject.res_subject ILIKE '%plain%'))\n" ' AND (ivoid IN (SELECT ivoid FROM rr.resource WHERE ' "1=ivo_hasword(res_description, 'string') UNION SELECT ivoid FROM rr.resource " "WHERE 1=ivo_hasword(res_title, 'string') UNION SELECT ivoid FROM " - "rr.res_subject WHERE res_subject ILIKE '%string%'))") + "rr.res_subject WHERE rr.res_subject.res_subject ILIKE '%string%'))") class TestSelectClause: