diff --git a/src/object_accessor.hpp b/src/object_accessor.hpp index fc86a62c..9727fe45 100644 --- a/src/object_accessor.hpp +++ b/src/object_accessor.hpp @@ -48,7 +48,7 @@ namespace realm { const ObjectSchema &get_object_schema() { return *m_object_schema; } Row row() { return m_row; } - bool is_valid() { return m_row.is_attached(); } + bool is_valid() const { return m_row.is_attached(); } private: SharedRealm m_realm; @@ -147,9 +147,7 @@ namespace realm { // template inline void Object::set_property_value(ContextType ctx, std::string prop_name, ValueType value, bool try_update) - { - verify_attached(); - + { const Property *prop = m_object_schema->property_for_name(prop_name); if (!prop) { throw InvalidPropertyException(m_object_schema->name, prop_name, @@ -161,8 +159,6 @@ namespace realm { template inline ValueType Object::get_property_value(ContextType ctx, std::string prop_name) { - verify_attached(); - const Property *prop = m_object_schema->property_for_name(prop_name); if (!prop) { throw InvalidPropertyException(m_object_schema->name, prop_name, @@ -176,6 +172,8 @@ namespace realm { { using Accessor = NativeAccessor; + verify_attached(); + if (!m_realm->is_in_transaction()) { throw MutationOutsideTransactionException("Can only set property values within a transaction."); } @@ -240,6 +238,8 @@ namespace realm { { using Accessor = NativeAccessor; + verify_attached(); + size_t column = property.table_column; if (property.is_nullable && m_row.is_null(column)) { return Accessor::null_value(ctx);