Add support for nullable string columns, and make NSString properties nullable by default

This commit is contained in:
Samuel E. Giddins 2015-04-16 16:48:07 -07:00
parent 107c2de9b6
commit 80b1642d32
3 changed files with 4 additions and 2 deletions

View File

@ -37,6 +37,7 @@ ObjectSchema::ObjectSchema(Group *group, const std::string &name) : name(name) {
property.type = (PropertyType)table->get_column_type(col);
property.is_indexed = table->has_search_index(col);
property.is_primary = false;
property.is_nullable = table->is_nullable(col) || property.type == PropertyTypeObject;
property.table_column = col;
if (property.type == PropertyTypeObject || property.type == PropertyTypeArray) {
// set link type for objects and arrays

View File

@ -197,7 +197,7 @@ void ObjectStore::update_column_mapping(Group *group, ObjectSchema &target_schem
}
static inline bool property_has_changed(Property &p1, Property &p2) {
return p1.type != p2.type || p1.name != p2.name || p1.object_type != p2.object_type;
return p1.type != p2.type || p1.name != p2.name || p1.object_type != p2.object_type || p1.is_nullable != p2.is_nullable;
}
// set references to tables on targetSchema and create/update any missing or out-of-date tables
@ -240,7 +240,7 @@ bool ObjectStore::create_tables(Group *group, ObjectStore::Schema &target_schema
break;
}
default:
target_prop.table_column = table->add_column(DataType(target_prop.type), target_prop.name);
target_prop.table_column = table->add_column(DataType(target_prop.type), target_prop.name, target_prop.is_nullable);
break;
}
changed = true;

View File

@ -52,6 +52,7 @@ namespace realm {
std::string object_type;
bool is_primary;
bool is_indexed;
bool is_nullable;
size_t table_column;
bool requires_index() { return is_primary || is_indexed; }