From b8d40950a723b4f84176ae454c20b09b916c692c Mon Sep 17 00:00:00 2001 From: Ari Lazier Date: Mon, 4 Jan 2016 15:54:03 -0800 Subject: [PATCH] remove invalid usage of const Schema --- results.cpp | 22 ++++++++++------------ shared_realm.cpp | 4 ++-- shared_realm.hpp | 4 ++-- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/results.cpp b/results.cpp index ea591276..32b00dda 100644 --- a/results.cpp +++ b/results.cpp @@ -171,9 +171,10 @@ size_t Results::index_of(Row const& row) throw DetatchedAccessorException{}; } if (m_table && row.get_table() != m_table) { - throw IncorrectTableException{ - ObjectStore::object_type_for_table_name(m_table->get_name()), - ObjectStore::object_type_for_table_name(row.get_table()->get_name())}; + throw IncorrectTableException(object_schema.name, + ObjectStore::object_type_for_table_name(row.get_table()->get_name()), + "Attempting to get the index of a Row of the wrong type" + ); } return index_of(row.get_index()); } @@ -323,11 +324,6 @@ TableView Results::get_tableview() REALM_UNREACHABLE(); } -StringData Results::get_object_type() const noexcept -{ - return ObjectStore::object_type_for_table_name(m_table->get_name()); -} - Results Results::sort(realm::SortOrder&& sort) const { return Results(m_realm, object_schema, get_query(), std::move(sort)); @@ -338,8 +334,10 @@ Results Results::filter(Query&& q) const return Results(m_realm, object_schema, get_query().and_query(std::move(q)), get_sort()); } -Results::UnsupportedColumnTypeException::UnsupportedColumnTypeException(size_t column, const Table* table) { - column_index = column; - column_name = table->get_column_name(column); - column_type = table->get_column_type(column); +Results::UnsupportedColumnTypeException::UnsupportedColumnTypeException(size_t column, const Table* table) +: column_index(column) +, column_name(table->get_column_name(column)) +, column_type(table->get_column_type(column)) +, std::runtime_error((std::string)"Operation not supported on '" + table->get_column_name(column).data() + "' columns") +{ } diff --git a/shared_realm.cpp b/shared_realm.cpp index aeeeaa28..c43f27db 100644 --- a/shared_realm.cpp +++ b/shared_realm.cpp @@ -193,13 +193,13 @@ SharedRealm Realm::get_shared_realm(Config config) return realm; } -bool Realm::update_schema(std::unique_ptr schema, uint64_t version) +bool Realm::update_schema(std::unique_ptr schema, uint64_t version) { schema->validate(); bool needs_update = !m_config.read_only && (m_config.schema_version != version || ObjectStore::needs_update(*m_config.schema, *schema)); if (!needs_update) { - ObjectStore::verify_schema(*m_config.schema, const_cast(*schema), m_config.read_only); + ObjectStore::verify_schema(*m_config.schema, *schema, m_config.read_only); m_config.schema = std::move(schema); m_config.schema_version = version; return false; diff --git a/shared_realm.hpp b/shared_realm.hpp index ffb86937..85e42224 100644 --- a/shared_realm.hpp +++ b/shared_realm.hpp @@ -52,7 +52,7 @@ namespace realm { bool disable_format_upgrade = false; std::vector encryption_key; - std::unique_ptr schema; + std::unique_ptr schema; uint64_t schema_version = ObjectStore::NotVersioned; MigrationFunction migration_function; @@ -80,7 +80,7 @@ namespace realm { // on the Config, and the resulting Schema and version with updated // column mappings are set on the realms config upon success. // returns if any changes were made - bool update_schema(std::unique_ptr schema, uint64_t version); + bool update_schema(std::unique_ptr schema, uint64_t version); static uint64_t get_schema_version(Config const& config);