Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More flexible schema work for RJS #7960

Merged
merged 4 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions bindgen/spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -811,20 +811,28 @@ classes:
- '(column: ColKey, value: Mixed)'
- sig: '(column: ColKey, value: Mixed, is_default: bool)'
suffix: with_default
- sig: '(column: StringData, value: Mixed)'
- sig: '(column: StringData, value: Mixed)'
suffix: by_name
set_collection:
- '(column: ColKey, type: CollectionType) -> Obj'
- sig: '(prop_name: StringData, type: CollectionType)'
suffix: by_name
set_collection: '(column: ColKey, type: CollectionType) -> Obj'
add_int: '(column: ColKey, value: int64_t) -> Obj'
get_linked_object: '(column: ColKey) const -> Nullable<Obj>'
to_string: () const -> std::string
get_backlink_count: '() const -> count_t'
erase_additional_prop: '(prop_name: StringData) const -> Obj'
get_additional_properties: '() -> std::vector<StringData>'
get_backlink_view: '(src_table: TableRef, src_col_key: ColKey) -> TableView'
create_and_set_linked_object: '(column: ColKey) -> Obj'
has_schema_property: '(column: StringData) -> bool'

get_collection_ptr: '(prop_name: StringData) -> CollectionPointer'
Transaction:
sharedPtrWrapped: TransactionRef

CollectionPointer:
cppName: CollectionBasePtr

ObjectStore:
staticMethods:
get_schema_version: '(group: Group) -> SchemaVersion'
Expand Down Expand Up @@ -1042,6 +1050,7 @@ classes:

Collection:
cppName: object_store::Collection
sharedPtrWrapped: SharedCollection
abstract: true
properties:
get_type: PropertyType
Expand Down Expand Up @@ -1070,6 +1079,7 @@ classes:
base: Collection
constructors:
make: '(r: SharedRealm, parent: const Obj&, col: ColKey)'
make_other: '(r: SharedRealm, parent: const Obj&, prop_name: StringData)'
methods:
get:
- sig: '(ndx: count_t) -> Obj'
Expand Down
5 changes: 5 additions & 0 deletions src/realm/object-store/collection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ Collection::Collection(const Object& parent_obj, const Property* prop)
{
}

Collection::Collection(std::shared_ptr<Realm> r, const Obj& parent_obj, const StringData prop_name)
: Collection(std::shared_ptr(r), parent_obj.get_collection_ptr(prop_name), PropertyType::Mixed)
{
}

Collection::Collection(std::shared_ptr<Realm> r, const Obj& parent_obj, ColKey col)
: Collection(std::move(r), parent_obj.get_collection_ptr(col),
ObjectSchema::from_core_type(col) & ~PropertyType::Collection)
Expand Down
1 change: 1 addition & 0 deletions src/realm/object-store/collection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Collection {
Collection(std::shared_ptr<Realm> r, const Obj& parent_obj, ColKey col);
Collection(std::shared_ptr<Realm> r, const CollectionBase& coll);
Collection(std::shared_ptr<Realm> r, CollectionBasePtr coll);
Collection(std::shared_ptr<Realm> r, const Obj& parent_obj, const StringData prop_name);

const std::shared_ptr<Realm>& get_realm() const
{
Expand Down
Loading