summaryrefslogtreecommitdiffstats
path: root/document
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@oath.com>2018-09-12 12:10:26 +0200
committerHenning Baldersheim <balder@oath.com>2018-09-12 12:12:47 +0200
commit3ede5bdf02f79649100af76da5eeec30a8491acf (patch)
tree3c33fcb81504a776f2cf9769d64a8f4a1d10e594 /document
parent6622ef49ea6a9336339dbe6ec6d54153d590ad30 (diff)
Identity only based on id.
Diffstat (limited to 'document')
-rw-r--r--document/src/vespa/document/datatype/datatype.cpp2
-rw-r--r--document/src/vespa/document/datatype/referencedatatype.cpp6
-rw-r--r--document/src/vespa/document/datatype/referencedatatype.h2
-rw-r--r--document/src/vespa/document/repo/documenttyperepo.cpp2
4 files changed, 10 insertions, 2 deletions
diff --git a/document/src/vespa/document/datatype/datatype.cpp b/document/src/vespa/document/datatype/datatype.cpp
index aef155999a4..8d2721a4d9b 100644
--- a/document/src/vespa/document/datatype/datatype.cpp
+++ b/document/src/vespa/document/datatype/datatype.cpp
@@ -159,7 +159,7 @@ DataType::~DataType() = default;
bool
DataType::operator==(const DataType& other) const
{
- return _dataTypeId == other._dataTypeId && _name == other._name;
+ return _dataTypeId == other._dataTypeId;
}
bool
diff --git a/document/src/vespa/document/datatype/referencedatatype.cpp b/document/src/vespa/document/datatype/referencedatatype.cpp
index 6792d95909c..7b7c83c7fa6 100644
--- a/document/src/vespa/document/datatype/referencedatatype.cpp
+++ b/document/src/vespa/document/datatype/referencedatatype.cpp
@@ -41,4 +41,10 @@ void ReferenceDataType::onBuildFieldPath(FieldPath &, vespalib::stringref remain
}
+bool ReferenceDataType::operator==(const DataType &rhs) const {
+ return DataType::operator==(rhs)
+ && rhs.inherits(classId)
+ && (_targetDocType == static_cast<const ReferenceDataType &>(rhs)._targetDocType);
+}
+
} // document
diff --git a/document/src/vespa/document/datatype/referencedatatype.h b/document/src/vespa/document/datatype/referencedatatype.h
index d5804d09835..5ca52f3ccb2 100644
--- a/document/src/vespa/document/datatype/referencedatatype.h
+++ b/document/src/vespa/document/datatype/referencedatatype.h
@@ -24,6 +24,8 @@ public:
void print(std::ostream&, bool verbose, const std::string& indent) const override;
ReferenceDataType* clone() const override;
void onBuildFieldPath(FieldPath & path, vespalib::stringref remainingFieldName) const override;
+
+ bool operator==(const DataType &type) const override;
};
} // document
diff --git a/document/src/vespa/document/repo/documenttyperepo.cpp b/document/src/vespa/document/repo/documenttyperepo.cpp
index 03b7660efbe..a320750e0d5 100644
--- a/document/src/vespa/document/repo/documenttyperepo.cpp
+++ b/document/src/vespa/document/repo/documenttyperepo.cpp
@@ -89,7 +89,7 @@ void Repo::inherit(const Repo &parent) {
bool Repo::addDataType(const DataType &type) {
const DataType *& data_type = _types[type.getId()];
if (data_type) {
- if (*data_type == type) {
+ if ((*data_type == type) && (data_type->getName() == type.getName())) {
return false; // Redefinition of identical type is ok.
}
throw IllegalArgumentException(