Update to core 0.100.1
This commit is contained in:
parent
449c4e6519
commit
507882d663
|
@ -9,7 +9,7 @@ include(CompilerFlags)
|
|||
include(Sanitizers)
|
||||
|
||||
include(RealmCore)
|
||||
set(REALM_CORE_VERSION "0.97.0" CACHE STRING "")
|
||||
set(REALM_CORE_VERSION "0.100.1" CACHE STRING "")
|
||||
use_realm_core(${REALM_CORE_VERSION})
|
||||
|
||||
include_directories(${REALM_CORE_INCLUDE_DIR} src external/pegtl)
|
||||
|
|
|
@ -124,7 +124,8 @@ public:
|
|||
bool set_double(size_t, size_t, double) { return true; }
|
||||
bool set_string(size_t, size_t, StringData) { return true; }
|
||||
bool set_binary(size_t, size_t, BinaryData) { return true; }
|
||||
bool set_date_time(size_t, size_t, DateTime) { return true; }
|
||||
bool set_olddatetime(size_t, size_t, OldDateTime) { return true; }
|
||||
bool set_timestamp(size_t, size_t, Timestamp) { return true; }
|
||||
bool set_table(size_t, size_t) { return true; }
|
||||
bool set_mixed(size_t, size_t, const Mixed&) { return true; }
|
||||
bool set_link(size_t, size_t, size_t, size_t) { return true; }
|
||||
|
@ -416,7 +417,8 @@ public:
|
|||
bool set_double(size_t col, size_t row, double) { return mark_dirty(row, col); }
|
||||
bool set_string(size_t col, size_t row, StringData) { return mark_dirty(row, col); }
|
||||
bool set_binary(size_t col, size_t row, BinaryData) { return mark_dirty(row, col); }
|
||||
bool set_date_time(size_t col, size_t row, DateTime) { return mark_dirty(row, col); }
|
||||
bool set_olddatetime(size_t col, size_t row, OldDateTime) { return mark_dirty(row, col); }
|
||||
bool set_timestamp(size_t col, size_t row, Timestamp) { return mark_dirty(row, col); }
|
||||
bool set_table(size_t col, size_t row) { return mark_dirty(row, col); }
|
||||
bool set_mixed(size_t col, size_t row, const Mixed&) { return mark_dirty(row, col); }
|
||||
bool set_link(size_t col, size_t row, size_t, size_t) { return mark_dirty(row, col); }
|
||||
|
|
|
@ -83,8 +83,8 @@ namespace realm {
|
|||
static ValueType from_string(ContextType, StringData);
|
||||
static std::string to_binary(ContextType, ValueType &);
|
||||
static ValueType from_binary(ContextType, BinaryData);
|
||||
static DateTime to_datetime(ContextType, ValueType &);
|
||||
static ValueType from_datetime(ContextType, DateTime);
|
||||
static Timestamp to_timestamp(ContextType, ValueType &);
|
||||
static ValueType from_timestamp(ContextType, Timestamp);
|
||||
|
||||
static bool is_null(ContextType, ValueType &);
|
||||
static ValueType null_value(ContextType);
|
||||
|
@ -194,7 +194,7 @@ namespace realm {
|
|||
m_row.set_mixed(column, Accessor::to_mixed(ctx, value));
|
||||
break;
|
||||
case PropertyTypeDate:
|
||||
m_row.set_datetime(column, Accessor::to_datetime(ctx, value));
|
||||
m_row.set_timestamp(column, Accessor::to_timestamp(ctx, value));
|
||||
break;
|
||||
case PropertyTypeObject: {
|
||||
if (Accessor::is_null(ctx, value)) {
|
||||
|
@ -246,7 +246,7 @@ namespace realm {
|
|||
case PropertyTypeAny:
|
||||
throw "Any not supported";
|
||||
case PropertyTypeDate:
|
||||
return Accessor::from_datetime(ctx, m_row.get_datetime(column));
|
||||
return Accessor::from_timestamp(ctx, m_row.get_timestamp(column));
|
||||
case PropertyTypeObject: {
|
||||
auto linkObjectSchema = m_realm->config().schema->find(property.object_type);
|
||||
TableRef table = ObjectStore::table_for_object_type(m_realm->read_group(), linkObjectSchema->name);
|
||||
|
|
|
@ -17,14 +17,29 @@
|
|||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "object_schema.hpp"
|
||||
|
||||
#include "object_store.hpp"
|
||||
#include "property.hpp"
|
||||
|
||||
#include <realm/group_shared.hpp>
|
||||
#include <realm/link_view.hpp>
|
||||
#include <realm/data_type.hpp>
|
||||
#include <realm/table.hpp>
|
||||
|
||||
using namespace realm;
|
||||
|
||||
#define ASSERT_PROPERTY_TYPE_VALUE(property, type) \
|
||||
static_assert(static_cast<int>(PropertyType##property) == type_##type, \
|
||||
"PropertyType and DataType must have the same values")
|
||||
|
||||
ASSERT_PROPERTY_TYPE_VALUE(Int, Int);
|
||||
ASSERT_PROPERTY_TYPE_VALUE(Bool, Bool);
|
||||
ASSERT_PROPERTY_TYPE_VALUE(Float, Float);
|
||||
ASSERT_PROPERTY_TYPE_VALUE(Double, Double);
|
||||
ASSERT_PROPERTY_TYPE_VALUE(Data, Binary);
|
||||
ASSERT_PROPERTY_TYPE_VALUE(Date, Timestamp);
|
||||
ASSERT_PROPERTY_TYPE_VALUE(Any, Mixed);
|
||||
ASSERT_PROPERTY_TYPE_VALUE(Object, Link);
|
||||
ASSERT_PROPERTY_TYPE_VALUE(Array, LinkList);
|
||||
|
||||
ObjectSchema::~ObjectSchema() = default;
|
||||
|
||||
ObjectSchema::ObjectSchema(std::string name, std::string primary_key, std::initializer_list<Property> properties)
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "schema.hpp"
|
||||
|
||||
#include <realm/group.hpp>
|
||||
#include <realm/link_view.hpp>
|
||||
#include <realm/table.hpp>
|
||||
#include <realm/table_view.hpp>
|
||||
#include <realm/util/assert.hpp>
|
||||
|
@ -128,15 +127,18 @@ std::string ObjectStore::table_name_for_object_type(StringData object_type) {
|
|||
}
|
||||
|
||||
TableRef ObjectStore::table_for_object_type(Group *group, StringData object_type) {
|
||||
return group->get_table(table_name_for_object_type(object_type));
|
||||
auto name = table_name_for_object_type(object_type);
|
||||
return group->get_table(name);
|
||||
}
|
||||
|
||||
ConstTableRef ObjectStore::table_for_object_type(const Group *group, StringData object_type) {
|
||||
return group->get_table(table_name_for_object_type(object_type));
|
||||
auto name = table_name_for_object_type(object_type);
|
||||
return group->get_table(name);
|
||||
}
|
||||
|
||||
TableRef ObjectStore::table_for_object_type_create_if_needed(Group *group, StringData object_type, bool &created) {
|
||||
return group->get_or_add_table(table_name_for_object_type(object_type), &created);
|
||||
auto name = table_name_for_object_type(object_type);
|
||||
return group->get_or_add_table(name, &created);
|
||||
}
|
||||
|
||||
static inline bool property_has_changed(Property const& p1, Property const& p2) {
|
||||
|
@ -241,7 +243,7 @@ static void copy_property_values(const Property& source, const Property& destina
|
|||
copy_property_values(source, destination, table, &Table::get_binary, &Table::set_binary);
|
||||
break;
|
||||
case PropertyTypeDate:
|
||||
copy_property_values(source, destination, table, &Table::get_datetime, &Table::set_datetime);
|
||||
copy_property_values(source, destination, table, &Table::get_timestamp, &Table::set_timestamp);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -304,14 +304,13 @@ template <typename RequestedType, typename TableGetter>
|
|||
struct ValueGetter;
|
||||
|
||||
template <typename TableGetter>
|
||||
struct ValueGetter<DateTime, TableGetter> {
|
||||
static Int convert(TableGetter&&, const parser::Expression & value, Arguments &args)
|
||||
struct ValueGetter<Timestamp, TableGetter> {
|
||||
static Timestamp convert(TableGetter&&, const parser::Expression & value, Arguments &args)
|
||||
{
|
||||
if (value.type != parser::Expression::Type::Argument) {
|
||||
throw std::runtime_error("You must pass in a date argument to compare");
|
||||
}
|
||||
DateTime dt = args.datetime_for_argument(stot<int>(value.s));
|
||||
return dt.get_datetime();
|
||||
return args.timestamp_for_argument(stot<int>(value.s));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -406,8 +405,8 @@ void do_add_comparison_to_query(Query &query, const Schema &schema, const Object
|
|||
value_of_type_for_query<bool>(expr.table_getter, rhs, args));
|
||||
break;
|
||||
case PropertyTypeDate:
|
||||
add_numeric_constraint_to_query(query, cmp.op, value_of_type_for_query<DateTime>(expr.table_getter, lhs, args),
|
||||
value_of_type_for_query<DateTime>(expr.table_getter, rhs, args));
|
||||
add_numeric_constraint_to_query(query, cmp.op, value_of_type_for_query<Timestamp>(expr.table_getter, lhs, args),
|
||||
value_of_type_for_query<Timestamp>(expr.table_getter, rhs, args));
|
||||
break;
|
||||
case PropertyTypeDouble:
|
||||
add_numeric_constraint_to_query(query, cmp.op, value_of_type_for_query<Double>(expr.table_getter, lhs, args),
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
#ifndef REALM_QUERY_BUILDER_HPP
|
||||
#define REALM_QUERY_BUILDER_HPP
|
||||
|
||||
#include <string>
|
||||
#include <realm/util/to_string.hpp>
|
||||
#include "parser.hpp"
|
||||
#include "object_accessor.hpp"
|
||||
|
||||
#include <realm/util/to_string.hpp>
|
||||
|
||||
namespace realm {
|
||||
class Query;
|
||||
class Schema;
|
||||
|
@ -31,10 +31,10 @@ class Schema;
|
|||
namespace query_builder {
|
||||
class Arguments;
|
||||
|
||||
void apply_predicate(Query &query, const parser::Predicate &predicate, Arguments &arguments, const Schema &schema, const std::string &objectType);
|
||||
void apply_predicate(Query &query, const parser::Predicate &predicate, Arguments &arguments,
|
||||
const Schema &schema, const std::string &objectType);
|
||||
|
||||
class Arguments
|
||||
{
|
||||
class Arguments {
|
||||
public:
|
||||
virtual bool bool_for_argument(size_t argument_index) = 0;
|
||||
virtual long long long_for_argument(size_t argument_index) = 0;
|
||||
|
@ -42,14 +42,13 @@ class Arguments
|
|||
virtual double double_for_argument(size_t argument_index) = 0;
|
||||
virtual std::string string_for_argument(size_t argument_index) = 0;
|
||||
virtual std::string binary_for_argument(size_t argument_index) = 0;
|
||||
virtual DateTime datetime_for_argument(size_t argument_index) = 0;
|
||||
virtual Timestamp timestamp_for_argument(size_t argument_index) = 0;
|
||||
virtual size_t object_index_for_argument(size_t argument_index) = 0;
|
||||
virtual bool is_argument_null(size_t argument_index) = 0;
|
||||
};
|
||||
|
||||
template<typename ValueType, typename ContextType>
|
||||
class ArgumentConverter : public Arguments
|
||||
{
|
||||
class ArgumentConverter : public Arguments {
|
||||
public:
|
||||
ArgumentConverter(ContextType context, std::vector<ValueType> arguments) : m_arguments(arguments), m_ctx(context) {};
|
||||
|
||||
|
@ -60,7 +59,7 @@ class ArgumentConverter : public Arguments
|
|||
virtual double double_for_argument(size_t argument_index) { return Accessor::to_double(m_ctx, argument_at(argument_index)); }
|
||||
virtual std::string string_for_argument(size_t argument_index) { return Accessor::to_string(m_ctx, argument_at(argument_index)); }
|
||||
virtual std::string binary_for_argument(size_t argument_index) { return Accessor::to_binary(m_ctx, argument_at(argument_index)); }
|
||||
virtual DateTime datetime_for_argument(size_t argument_index) { return Accessor::to_datetime(m_ctx, argument_at(argument_index)); }
|
||||
virtual Timestamp timestamp_for_argument(size_t argument_index) { return Accessor::to_timestamp(m_ctx, argument_at(argument_index)); }
|
||||
virtual size_t object_index_for_argument(size_t argument_index) { return Accessor::to_existing_object_index(m_ctx, argument_at(argument_index)); }
|
||||
virtual bool is_argument_null(size_t argument_index) { return Accessor::is_null(m_ctx, argument_at(argument_index)); }
|
||||
|
||||
|
|
|
@ -23,25 +23,15 @@
|
|||
|
||||
namespace realm {
|
||||
enum PropertyType {
|
||||
/** Integer type: NSInteger, int, long, Int (Swift) */
|
||||
PropertyTypeInt = 0,
|
||||
/** Boolean type: BOOL, bool, Bool (Swift) */
|
||||
PropertyTypeBool = 1,
|
||||
/** Float type: CGFloat (32bit), float, Float (Swift) */
|
||||
PropertyTypeFloat = 9,
|
||||
/** Double type: CGFloat (64bit), double, Double (Swift) */
|
||||
PropertyTypeDouble = 10,
|
||||
/** String type: NSString, String (Swift) */
|
||||
PropertyTypeString = 2,
|
||||
/** Data type: NSData */
|
||||
PropertyTypeData = 4,
|
||||
/** Any type: id, **not supported in Swift** */
|
||||
PropertyTypeAny = 6,
|
||||
/** Date type: NSDate */
|
||||
PropertyTypeDate = 7,
|
||||
/** Object type. See [Realm Models](http://realm.io/docs/cocoa/latest/#models) */
|
||||
PropertyTypeAny = 6, // deprecated and will be removed in the future
|
||||
PropertyTypeDate = 8,
|
||||
PropertyTypeObject = 12,
|
||||
/** Array type. See [Realm Models](http://realm.io/docs/cocoa/latest/#models) */
|
||||
PropertyTypeArray = 13,
|
||||
};
|
||||
|
||||
|
@ -55,7 +45,13 @@ namespace realm {
|
|||
|
||||
size_t table_column = -1;
|
||||
bool requires_index() const { return is_primary || is_indexed; }
|
||||
bool is_indexable() const { return type == PropertyTypeInt || type == PropertyTypeBool || type == PropertyTypeString || type == PropertyTypeDate; }
|
||||
bool is_indexable() const
|
||||
{
|
||||
return type == PropertyTypeInt
|
||||
|| type == PropertyTypeBool
|
||||
|| type == PropertyTypeDate
|
||||
|| type == PropertyTypeString;
|
||||
}
|
||||
};
|
||||
|
||||
static inline const char *string_for_property_type(PropertyType type) {
|
||||
|
|
|
@ -221,10 +221,10 @@ size_t Results::index_of(size_t row_ndx)
|
|||
REALM_UNREACHABLE();
|
||||
}
|
||||
|
||||
template<typename Int, typename Float, typename Double, typename DateTime>
|
||||
template<typename Int, typename Float, typename Double, typename Timestamp>
|
||||
util::Optional<Mixed> Results::aggregate(size_t column, bool return_none_for_empty,
|
||||
Int agg_int, Float agg_float,
|
||||
Double agg_double, DateTime agg_datetime)
|
||||
Double agg_double, Timestamp agg_timestamp)
|
||||
{
|
||||
validate_read();
|
||||
if (!m_table)
|
||||
|
@ -252,7 +252,7 @@ util::Optional<Mixed> Results::aggregate(size_t column, bool return_none_for_emp
|
|||
|
||||
switch (m_table->get_column_type(column))
|
||||
{
|
||||
case type_DateTime: return do_agg(agg_datetime);
|
||||
case type_Timestamp: return do_agg(agg_timestamp);
|
||||
case type_Double: return do_agg(agg_double);
|
||||
case type_Float: return do_agg(agg_float);
|
||||
case type_Int: return do_agg(agg_int);
|
||||
|
@ -267,7 +267,7 @@ util::Optional<Mixed> Results::max(size_t column)
|
|||
[=](auto const& table) { return table.maximum_int(column); },
|
||||
[=](auto const& table) { return table.maximum_float(column); },
|
||||
[=](auto const& table) { return table.maximum_double(column); },
|
||||
[=](auto const& table) { return table.maximum_datetime(column); });
|
||||
[=](auto const& table) { return table.maximum_timestamp(column); });
|
||||
}
|
||||
|
||||
util::Optional<Mixed> Results::min(size_t column)
|
||||
|
@ -276,7 +276,7 @@ util::Optional<Mixed> Results::min(size_t column)
|
|||
[=](auto const& table) { return table.minimum_int(column); },
|
||||
[=](auto const& table) { return table.minimum_float(column); },
|
||||
[=](auto const& table) { return table.minimum_double(column); },
|
||||
[=](auto const& table) { return table.minimum_datetime(column); });
|
||||
[=](auto const& table) { return table.minimum_timestamp(column); });
|
||||
}
|
||||
|
||||
util::Optional<Mixed> Results::sum(size_t column)
|
||||
|
|
|
@ -134,7 +134,7 @@ public:
|
|||
// Get the min/max/average/sum of the given column
|
||||
// All but sum() returns none when there are zero matching rows
|
||||
// sum() returns 0, except for when it returns none
|
||||
// Throws UnsupportedColumnTypeException for sum/average on datetime or non-numeric column
|
||||
// Throws UnsupportedColumnTypeException for sum/average on timestamp or non-numeric column
|
||||
// Throws OutOfBoundsIndexException for an out-of-bounds column
|
||||
util::Optional<Mixed> max(size_t column);
|
||||
util::Optional<Mixed> min(size_t column);
|
||||
|
@ -225,10 +225,10 @@ private:
|
|||
void validate_read() const;
|
||||
void validate_write() const;
|
||||
|
||||
template<typename Int, typename Float, typename Double, typename DateTime>
|
||||
template<typename Int, typename Float, typename Double, typename Timestamp>
|
||||
util::Optional<Mixed> aggregate(size_t column, bool return_none_for_empty,
|
||||
Int agg_int, Float agg_float,
|
||||
Double agg_double, DateTime agg_datetime);
|
||||
Double agg_double, Timestamp agg_timestamp);
|
||||
|
||||
void set_table_view(TableView&& tv);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue