Skip to content

Commit

Permalink
Merge eb26a4c into c7b0758
Browse files Browse the repository at this point in the history
  • Loading branch information
desistefanova committed Feb 14, 2022
2 parents c7b0758 + eb26a4c commit c7e0e4d
Show file tree
Hide file tree
Showing 14 changed files with 284 additions and 13 deletions.
22 changes: 21 additions & 1 deletion .github/workflows/realm-dart-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,20 @@ on:
push:
branches:
- master
paths-ignore:
- 'flutter/**'
- 'generator/**'
- '.github/**'
- '!.github/workflows/realm-dart-linux.yml' # except this one
tags:
- '[0-9]+.[0-9]+.[0-9]+**' # matches tags like number(s).number(s).number(s)(any) for ex: 1.0.0 and also 1.0.0+beta

pull_request:
paths-ignore:
- 'flutter/**'
- 'generator/**'
- '.github/**'
- '!.github/workflows/realm-dart-linux.yml' # except this one

jobs:
CI:
Expand Down Expand Up @@ -45,6 +56,9 @@ jobs:
dart run realm_dart archive --source-dir $(pwd)/binary/linux --output-file $ARCHIVE_PATH
- name: Release artifacts
# env:
# EVENT_CONTEXT: ${{ toJSON(github.event) }}
# EVENT_CONTEXT: ${{ toJSON(github) }}
if: ${{ success() && github.event_name == 'push' && github.ref_type == 'tag' }}
uses: ncipollo/release-action@v1
with:
Expand All @@ -57,4 +71,10 @@ jobs:
artifacts: ${{ env.ARCHIVE_PATH }}
body: "ADD RELEASE NOTES"
omitBodyDuringUpdate: true
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
# run: |
# echo "Creating a release for tag ${{ github.ref_name }}"
# # echo $EVENT_CONTEXT
# # echo "github.event_name ${{ github.event_name }}"
# # echo "github.ref_type ${{ github.ref_type }}"
# # echo "github.ref_name ${{ github.ref_name }}"
13 changes: 12 additions & 1 deletion .github/workflows/realm-dart-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,20 @@ on:
push:
branches:
- master
paths-ignore:
- 'flutter/**'
- 'generator/**'
- '.github/**'
- '!.github/workflows/realm-dart-macos.yml' # except this one
tags:
- '[0-9]+.[0-9]+.[0-9]+**' # matches tags like number(s).number(s).number(s)(any) for ex: 1.0.0 and also 1.0.0+beta

pull_request:
paths-ignore:
- 'flutter/**'
- 'generator/**'
- '.github/**'
- '!.github/workflows/realm-dart-macos.yml' # except this one

jobs:
CI:
Expand All @@ -30,7 +41,7 @@ jobs:
- name : Setup Dart SDK
uses: dart-lang/setup-dart@main
with:
sdk: stable
sdk: beta

- name: Install dependencies
run: dart pub get
Expand Down
24 changes: 23 additions & 1 deletion .github/workflows/realm-dart-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,20 @@ on:
push:
branches:
- master
paths-ignore:
- 'flutter/**'
- 'generator/**'
- '.github/**'
- '!.github/workflows/realm-dart-windows.yml' # except this one
tags:
- '[0-9]+.[0-9]+.[0-9]+**' # matches tags like number(s).number(s).number(s)(any) for ex: 1.0.0 and also 1.0.0+beta

pull_request:
paths-ignore:
- 'flutter/**'
- 'generator/**'
- '.github/**'
- '!.github/workflows/realm-dart-windows.yml' # except this one

jobs:
CI:
Expand All @@ -15,6 +26,17 @@ jobs:
REALM_CI: true

steps:
# - name: SET VARS
# run: |
# echo "ARCHIVE_PATH=$(pwd)\\binary\\windows.tar.gz" >> $env:GITHUB_ENV
# echo "ARCHIVE_SOURCE_PATH=$(pwd)\\binary" >> $env:GITHUB_ENV
# - name: PRINT VARS
# run: |
# echo $ARCHIVE_PATH
# echo $ARCHIVE_SOURCE_PATH
# echo ${{ env.ARCHIVE_PATH }}
# echo ${{ env.ARCHIVE_SOURCE_PATH }}

- name: Checkout
uses: actions/checkout@v2
with:
Expand All @@ -30,7 +52,7 @@ jobs:
- name : Setup Dart SDK
uses: dart-lang/setup-dart@main
with:
sdk: stable
sdk: beta

- name: Install dependencies
run: dart pub get
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/realm-flutter-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@ on:
push:
branches:
- master
paths-ignore:
- 'generator/**'
- '.github/**'
- '!.github/workflows/realm-flutter-android.yml' # except this one
tags:
- '[0-9]+.[0-9]+.[0-9]+**' # matches tags like number(s).number(s).number(s)(any) for ex: 1.0.0 and also 1.0.0+beta

pull_request:
paths-ignore:
- 'generator/**'
- '.github/**'
- '!.github/workflows/realm-flutter-android.yml' # except this one

jobs:
CI:
Expand Down Expand Up @@ -35,7 +44,7 @@ jobs:
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
channel: 'beta'

- name: Install dependencies
run: flutter pub get
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/realm-flutter-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@ on:
push:
branches:
- master
paths-ignore:
- 'generator/**'
- '.github/**'
- '!.github/workflows/realm-flutter-ios.yml' # except this one
tags:
- '[0-9]+.[0-9]+.[0-9]+**' # matches tags like number(s).number(s).number(s)(any) for ex: 1.0.0 and also 1.0.0+beta

pull_request:
paths-ignore:
- 'generator/**'
- '.github/**'
- '!.github/workflows/realm-flutter-ios.yml' # except this one

jobs:
CI:
Expand Down Expand Up @@ -47,7 +56,7 @@ jobs:
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
channel: 'beta'

- name: Install dependencies
run: flutter pub get
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/realm-flutter-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@ on:
push:
branches:
- master
paths-ignore:
- 'generator/**'
- '.github/**'
- '!.github/workflows/realm-flutter-macos.yml' # except this one
tags:
- '[0-9]+.[0-9]+.[0-9]+**' # matches tags like number(s).number(s).number(s)(any) for ex: 1.0.0 and also 1.0.0+beta

pull_request:
paths-ignore:
- 'generator/**'
- '.github/**'
- '!.github/workflows/realm-flutter-macos.yml' # except this one

jobs:
CI:
Expand All @@ -26,7 +35,7 @@ jobs:
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
channel: 'beta'

- name: Enable Flutter Desktop support
run: flutter config --enable-macos-desktop
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/realm-flutter-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@ on:
push:
branches:
- master
paths-ignore:
- 'generator/**'
- '.github/**'
- '!.github/workflows/realm-flutter-windows.yml' # except this one
tags:
- '[0-9]+.[0-9]+.[0-9]+**' # matches tags like number(s).number(s).number(s)(any) for ex: 1.0.0 and also 1.0.0+beta

pull_request:
paths-ignore:
- 'generator/**'
- '.github/**'
- '!.github/workflows/realm-flutter-windows.yml' # except this one

jobs:
CI:
Expand All @@ -26,7 +35,7 @@ jobs:
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
channel: 'beta'

- name: Enable Flutter Desktop support
run: flutter config --enable-windows-desktop
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/realm-generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ on:
push:
branches:
- master
paths:
- 'generator/**'
- .github/workflows/realm-generator.yml

pull_request:
paths:
- 'generator/**'
- .github/workflows/realm-generator.yml

jobs:
CI:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ vNext

### Changes
* Primary key annotation no longer requires field to be final.
* `RealmObject.IsValid` can be called to check if a managed object has been deleted and its Realm isn't closed. If RealmObject is no longer valid accessing its properties will throw an exception. ([#183](https://github.com/realm/realm-dart/pull/183))
* `RealmList.IsValid` can be called to check whether the Realm instance hasn't been closed, whether it represents a to-many relationship and it's parent object hasn't been deleted. ([#183](https://github.com/realm/realm-dart/pull/183))

### Enhancements
* Support query on lists of realm objects
Expand Down
2 changes: 1 addition & 1 deletion lib/src/cli/install/install_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ class InstallCommand extends Command<void> {
Future<String> getRealmPackagePath() async {
final packageConfig = await findPackageConfig(Directory.current);
if (packageConfig == null) {
throw Exception("Package configuration not found. "
throw Exception("Package configuration ('package_config.json' or '.packages') not found. "
"Run the 'dart run $packageName install` command from the root directory of your application");
}

Expand Down
9 changes: 8 additions & 1 deletion lib/src/list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ class RealmList<T extends Object> extends collection.ListBase<T> {
void clear() {
realmCore.listClear(this);
}

/// Gets a value indicating whether this collection is still valid to use.
///
/// Indicates whether the [Realm] instance hasn't been closed,
/// if it represents a to-many relationship
/// and it's parent object hasn't been deleted.
bool get isValid => realmCore.listIsValid(this);
}

// The query operations on lists only work for list of objects (core restriction),
Expand All @@ -90,7 +97,7 @@ extension RealmListOfObject<T extends RealmObject> on RealmList<T> {
/// Filters the list and returns a new [RealmResults] according to the provided query.
///
/// Only works for lists of Realm objects.
///
///
/// @param query The query used to filter the list
/// @param args Optional parameters for substitution in the query
///
Expand Down
8 changes: 8 additions & 0 deletions lib/src/native/realm_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,14 @@ class _RealmCore {
bool equals(RealmObject first, RealmObject second) {
return _realmLib.realm_equals(first.handle._pointer.cast(), second.handle._pointer.cast());
}

bool objectIsValid(RealmObject object) {
return _realmLib.realm_object_is_valid(object.handle._pointer);
}

bool listIsValid(RealmList list) {
return _realmLib.realm_list_is_valid(list.handle._pointer);
}
}

class LastError {
Expand Down
12 changes: 10 additions & 2 deletions lib/src/realm_object.dart
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ class RealmCoreAccessor implements RealmAccessor {
/// An object that is persisted in `Realm`.
///
/// `RealmObjects` are generated from Realm data model classes marked with `@RealmModel` annotation and named with an underscore.
///
///
/// A data model class `_MyClass` will have a `RealmObject` generated with name `MyClass`.
///
///
/// [RealmObject] should not be used directly as it is part of the generated class hierarchy. ex: `MyClass extends _MyClass with RealmObject`.
/// {@category Realm}
class RealmObject {
Expand Down Expand Up @@ -224,6 +224,14 @@ class RealmObject {
if (!isManaged || !other.isManaged) return false;
return realmCore.equals(this, other);
}

/// Gets a value indicating whether this object is managed and represents a row in the database.
///
/// If a managed object has been removed from the [Realm], it is no longer valid and accessing properties on it
/// will throw an exception.
/// The Object is not valid if its [Realm] is closed or object is deleted.
/// Unmanaged objects are always considered valid.
bool get isValid => isManaged ? realmCore.objectIsValid(this) : true;
}

/// @nodoc
Expand Down

0 comments on commit c7e0e4d

Please sign in to comment.