diff --git a/frameworks/libs/distributeddb/storage/include/cloud/schema_mgr.h b/frameworks/libs/distributeddb/storage/include/cloud/schema_mgr.h index 71ffce60311140163e7e9833d0f12cc4c5144031..dbb2533ee14baee4284486e1bdf12946d11946a3 100644 --- a/frameworks/libs/distributeddb/storage/include/cloud/schema_mgr.h +++ b/frameworks/libs/distributeddb/storage/include/cloud/schema_mgr.h @@ -38,6 +38,8 @@ public: private: bool IsAssetPrimaryField(const Field &cloudField); + std::string GetStorageTypeName(StorageType type); + std::string GetCloudTypeName(int32_t type); bool CompareType(const FieldInfo &localField, const Field &cloudField); bool CompareNullable(const FieldInfo &localField, const Field &cloudField); bool ComparePrimaryField(std::map &localPrimaryKeys, const Field &cloudField); diff --git a/frameworks/libs/distributeddb/storage/src/cloud/schema_mgr.cpp b/frameworks/libs/distributeddb/storage/src/cloud/schema_mgr.cpp index 4f5eca04255b7fc301431d1705520b8646b6f62f..fac6dbb350e823235c3a6b7bdb1a51e056e22653 100644 --- a/frameworks/libs/distributeddb/storage/src/cloud/schema_mgr.cpp +++ b/frameworks/libs/distributeddb/storage/src/cloud/schema_mgr.cpp @@ -71,15 +71,24 @@ int SchemaMgr::CompareFieldSchema(std::map &primaryKeys, FieldIn } FieldInfo &localField = localFields[cloudField.colName]; if (!CompareType(localField, cloudField)) { - LOGE("Type mismatch between local and cloud schema"); + LOGE("Type mismatch for field [%s]: local=%s, cloud=%s", + DBCommon::StringMiddleMasking(cloudField.colName).c_str(), + GetStorageTypeName(localField.GetStorageType()).c_str(), + GetCloudTypeName(cloudField.type).c_str()); return -E_SCHEMA_MISMATCH; } if (!CompareNullable(localField, cloudField)) { - LOGE("The nullable property is mismatched between local and cloud schema"); + LOGE("Nullable mismatch for field [%s]: local=%s, cloud=%s", + DBCommon::StringMiddleMasking(cloudField.colName).c_str(), + localField.IsNotNull() ? "NOT_NULL" : "NULLABLE", + cloudField.nullable ? "NULLABLE" : "NOT_NULL"); return -E_SCHEMA_MISMATCH; } if (!ComparePrimaryField(primaryKeys, cloudField)) { - LOGE("The primary key property is mismatched between local and cloud schema"); + LOGE("Primary key mismatch for field [%s]: local=%s, cloud=%s", + DBCommon::StringMiddleMasking(cloudField.colName).c_str(), + cloudField.primary ? "NOT_PRIMARY" : "PRIMARY", + cloudField.primary ? "PRIMARY" : "NOT_PRIMARY"); return -E_SCHEMA_MISMATCH; } cloudColNames.emplace(cloudField.colName); @@ -104,6 +113,33 @@ bool SchemaMgr::IsAssetPrimaryField(const Field &cloudField) return cloudField.primary && (cloudField.type == TYPE_INDEX || cloudField.type == TYPE_INDEX); } +std::string SchemaMgr::GetStorageTypeName(StorageType type) +{ + switch (type) { + case StorageType::STORAGE_TYPE_NULL: return "NULL"; + case StorageType::STORAGE_TYPE_INTEGER: return "INTEGER"; + case StorageType::STORAGE_TYPE_REAL: return "REAL"; + case StorageType::STORAGE_TYPE_TEXT: return "TEXT"; + case StorageType::STORAGE_TYPE_BLOB: return "BLOB"; + default: return "UNKNOWN"; + } +} + +std::string SchemaMgr::GetCloudTypeName(int32_t type) +{ + switch (type) { + case TYPE_INDEX: return "NULL"; + case TYPE_INDEX: return "BOOL"; + case TYPE_INDEX: return "INTEGER"; + case TYPE_INDEX: return "REAL"; + case TYPE_INDEX: return "TEXT"; + case TYPE_INDEX: return "BLOB"; + case TYPE_INDEX: return "ASSET"; + case TYPE_INDEX: return "ASSETS"; + default: return "UNKNOWN"; + } +} + bool SchemaMgr::CompareType(const FieldInfo &localField, const Field &cloudField) { StorageType localType = localField.GetStorageType();