From 9045d7945381c09c4ade792241bfd426d4725eec Mon Sep 17 00:00:00 2001 From: kishikawa katsumi Date: Sat, 9 Jan 2016 00:47:39 +0900 Subject: [PATCH] Bool and NSDate properties can be indexed. Core supports indexing Bool and NSDate properties. realm-java also supports indexing Bool and NSDate properties. It is better to align the specification with realm-java. --- src/property.hpp | 1 + src/schema.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/property.hpp b/src/property.hpp index 05993ae1..fa8b0ec3 100644 --- a/src/property.hpp +++ b/src/property.hpp @@ -55,6 +55,7 @@ namespace realm { size_t table_column = -1; bool requires_index() const { return is_primary || is_indexed; } + bool is_indexable() const { return type == PropertyTypeInt || type == PropertyTypeBool || type == PropertyTypeString || type == PropertyTypeDate; } }; static inline const char *string_for_property_type(PropertyType type) { diff --git a/src/schema.cpp b/src/schema.cpp index 911dc4e5..3d3988d7 100644 --- a/src/schema.cpp +++ b/src/schema.cpp @@ -89,7 +89,7 @@ void Schema::validate() const // check indexable if (prop.is_indexed) { - if (prop.type != PropertyTypeString && prop.type != PropertyTypeInt) { + if (!prop.is_indexable()) { exceptions.emplace_back(PropertyTypeNotIndexableException(object.name, prop)); } }