summaryrefslogtreecommitdiffstats
path: root/document
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@yahooinc.com>2022-05-30 12:56:18 +0000
committergjoranv <gv@verizonmedia.com>2022-06-08 11:45:22 +0200
commitc822b8d15186eed0041f4165ae9ee128c4e838eb (patch)
treee8ce48c0d4b036f259633fba979126960cc6c7aa /document
parent481fadf54a43cc678e5d85e4c37cc75a53a6d128 (diff)
Use exact document type matching semantics for C++ document selector implementation
Diffstat (limited to 'document')
-rw-r--r--document/src/tests/documentselectparsertest.cpp6
-rw-r--r--document/src/vespa/document/select/doctype.cpp10
-rw-r--r--document/src/vespa/document/select/valuenodes.cpp9
3 files changed, 5 insertions, 20 deletions
diff --git a/document/src/tests/documentselectparsertest.cpp b/document/src/tests/documentselectparsertest.cpp
index 1606cbc634d..464d3c66a7a 100644
--- a/document/src/tests/documentselectparsertest.cpp
+++ b/document/src/tests/documentselectparsertest.cpp
@@ -673,8 +673,8 @@ TEST_F(DocumentSelectParserTest, operators_1)
// Inherited doctypes
PARSE("testdoctype2", *_doc[4], True);
PARSE("testdoctype2", *_doc[3], False);
- PARSE("testdoctype1", *_doc[4], True);
- PARSE("testdoctype1.headerval = 10", *_doc[4], True);
+ PARSE("testdoctype1", *_doc[4], False); // testdoctype2 inherits testdoctype1, but we use exact matching for types
+ PARSE("testdoctype1.headerval = 10", *_doc[4], Invalid);
}
TEST_F(DocumentSelectParserTest, operators_2)
@@ -1182,7 +1182,7 @@ void DocumentSelectParserTest::testDocumentUpdates1()
// Inherited doctypes
PARSE("testdoctype2", *_update[4], True);
PARSE("testdoctype2", *_update[3], False);
- PARSE("testdoctype1", *_update[4], True);
+ PARSE("testdoctype1", *_update[4], False); // testdoctype2 inherits testdoctype1, but we use exact matching for types
PARSE("testdoctype1.headerval = 10", *_update[4], Invalid);
}
diff --git a/document/src/vespa/document/select/doctype.cpp b/document/src/vespa/document/select/doctype.cpp
index 800e8aa34b4..c86fd20e4f1 100644
--- a/document/src/vespa/document/select/doctype.cpp
+++ b/document/src/vespa/document/select/doctype.cpp
@@ -14,15 +14,7 @@ namespace {
bool documentTypeEqualsName(const DocumentType& type,
vespalib::stringref name)
{
- if (type.getName() == name) return true;
- // TODO Vespa 8: Remove this for loop on Vespa 8
- for (std::vector<const DocumentType *>::const_iterator it
- = type.getInheritedTypes().begin();
- it != type.getInheritedTypes().end(); ++it)
- {
- if (documentTypeEqualsName(**it, name)) return true;
- }
- return false;
+ return (type.getName() == name);
}
}
diff --git a/document/src/vespa/document/select/valuenodes.cpp b/document/src/vespa/document/select/valuenodes.cpp
index 452779ca5ba..8102a944ff0 100644
--- a/document/src/vespa/document/select/valuenodes.cpp
+++ b/document/src/vespa/document/select/valuenodes.cpp
@@ -22,14 +22,7 @@ namespace document::select {
namespace {
bool documentTypeEqualsName(const DocumentType& type, vespalib::stringref name)
{
- if (type.getName() == name) return true;
- for (std::vector<const DocumentType *>::const_iterator it
- = type.getInheritedTypes().begin();
- it != type.getInheritedTypes().end(); ++it)
- {
- if (documentTypeEqualsName(**it, name)) return true;
- }
- return false;
+ return (type.getName() == name);
}
}