remove invalid usage of const Schema

This commit is contained in:
Ari Lazier 2016-01-04 15:54:03 -08:00
parent ebce831522
commit b8d40950a7
3 changed files with 14 additions and 16 deletions

View File

@ -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")
{
}

View File

@ -193,13 +193,13 @@ SharedRealm Realm::get_shared_realm(Config config)
return realm;
}
bool Realm::update_schema(std::unique_ptr<const Schema> schema, uint64_t version)
bool Realm::update_schema(std::unique_ptr<Schema> 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 &>(*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;

View File

@ -52,7 +52,7 @@ namespace realm {
bool disable_format_upgrade = false;
std::vector<char> encryption_key;
std::unique_ptr<const Schema> schema;
std::unique_ptr<Schema> 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<const Schema> schema, uint64_t version);
bool update_schema(std::unique_ptr<Schema> schema, uint64_t version);
static uint64_t get_schema_version(Config const& config);