mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-11 06:46:03 +00:00
Add support for nullable string columns, and make NSString properties nullable by default
This commit is contained in:
parent
107c2de9b6
commit
80b1642d32
@ -37,6 +37,7 @@ ObjectSchema::ObjectSchema(Group *group, const std::string &name) : name(name) {
|
|||||||
property.type = (PropertyType)table->get_column_type(col);
|
property.type = (PropertyType)table->get_column_type(col);
|
||||||
property.is_indexed = table->has_search_index(col);
|
property.is_indexed = table->has_search_index(col);
|
||||||
property.is_primary = false;
|
property.is_primary = false;
|
||||||
|
property.is_nullable = table->is_nullable(col) || property.type == PropertyTypeObject;
|
||||||
property.table_column = col;
|
property.table_column = col;
|
||||||
if (property.type == PropertyTypeObject || property.type == PropertyTypeArray) {
|
if (property.type == PropertyTypeObject || property.type == PropertyTypeArray) {
|
||||||
// set link type for objects and arrays
|
// set link type for objects and arrays
|
||||||
|
@ -197,7 +197,7 @@ void ObjectStore::update_column_mapping(Group *group, ObjectSchema &target_schem
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline bool property_has_changed(Property &p1, Property &p2) {
|
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
|
// 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;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
changed = true;
|
changed = true;
|
||||||
|
@ -52,6 +52,7 @@ namespace realm {
|
|||||||
std::string object_type;
|
std::string object_type;
|
||||||
bool is_primary;
|
bool is_primary;
|
||||||
bool is_indexed;
|
bool is_indexed;
|
||||||
|
bool is_nullable;
|
||||||
|
|
||||||
size_t table_column;
|
size_t table_column;
|
||||||
bool requires_index() { return is_primary || is_indexed; }
|
bool requires_index() { return is_primary || is_indexed; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user