Skip to content

Commit

Permalink
Merge branch 'master' into releases
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
cmelchior committed Aug 27, 2021
2 parents 5a405e1 + 79723ab commit db6b3e3
Show file tree
Hide file tree
Showing 14 changed files with 266 additions and 88 deletions.
100 changes: 100 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Bug Report
description: Report a bug
labels: [T-Bug]
body:
- type: markdown
attributes:
value: |
Please provide as much detail as you can so we have a better chance of fixing the bug quickly.
Thanks for your contribution to improve this project!
- type: dropdown
id: frequency
attributes:
label: How frequently does the bug occur?
options:
- Seen once
- Sometimes
- All the time
validations:
required: true
# Description
- type: textarea
id: description
attributes:
label: Description
description: |
Describe what you were expecting and what actually happened.
validations:
required: true
- type: textarea
id: stacktrace
attributes:
label: Stacktrace & log output
description: Please paste any relevant log output or stacktrace if you're getting an exception/crash.
render: shell
# Repro information
- type: dropdown
id: repro
attributes:
label: Can you reproduce the bug?
options:
- Yes, always
- Yes, sometimes
- Not yet
validations:
required: true
- type: textarea
id: code-snippets
attributes:
label: Reproduction Steps
description: |
If you can reproduce the bug, please provide detailed steps for how WE can reproduce it.
Ideally, please provide a self contained test case or link (e.g. github repo) to a sample app that demonstrates the bug.
If that's not possible, please show code samples that highlight or reproduce the issue.
If relevant, include your model definitions.
Should you need to share code confidentially, you can send a link to: realm-help (the @) mongodb.com.
# Version
- type: input
id: version
attributes:
label: Version
description: What version(s) of the SDK has the bug been observed in?
validations:
required: true
- type: dropdown
id: sync
attributes:
label: What SDK flavour are you using?
options:
- Local Database only
- MongoDB Realm (i.e. Sync, auth, functions)
validations:
required: true
- type: dropdown
id: encryption
attributes:
label: Are you using encryption?
options:
- Yes, using encryption
- No, not using encryption
validations:
required: true
# Environment
- type: input
id: platform
attributes:
label: Platform OS and version(s)
description: OS and version(s) are you seeing the issue on?
validations:
required: true
- type: textarea
id: java-build-environment
attributes:
label: "Build environment"
description: Build environment versions
value: |
Android Studio version: ...
Android Build Tools version: ...
Gradle version: ...
validations:
required: false
30 changes: 0 additions & 30 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
blank_issues_enabled: true
contact_links:
- name: General Questions and Inquiries
url: https://www.mongodb.com/community/forums/tags/c/realm-sdks/58/java
about: Please ask general design/architecture questions in the community forums.
- name: MongoDB Realm (Sync) Production Issues
url: https://support.mongodb.com/
about: Please report urgent production issues to the support portal directly.
40 changes: 40 additions & 0 deletions .github/ISSUE_TEMPLATE/feature.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Feature Request
description: Request a new feature or enhancement
labels: [T-Enhancement]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to suggest improvements to the SDK!
- type: textarea
id: problem
attributes:
label: Problem
description: A clear and concise description of the problem you are trying to solve.
validations:
required: true
- type: textarea
id: solution
attributes:
label: Solution
description: Describe the solution you envision, including API and usage example if possible.
validations:
required: false
- type: textarea
id: alternative-solution
attributes:
label: Alternatives
description: Describe the alternative solutions or features you have considered
validations:
required: false
- type: dropdown
id: importance
attributes:
label: How important is this improvement for you?
options:
- Dealbreaker
- Would be a major improvement
- I'd like to see it, but have a workaround
- Fairly niche, but nice to have anyway.
validations:
required: false
16 changes: 0 additions & 16 deletions .github/ISSUE_TEMPLATE/feature_request.md

This file was deleted.

18 changes: 0 additions & 18 deletions .github/ISSUE_TEMPLATE/question.md

This file was deleted.

6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
## 10.7.2 (YYYY-MM-DD)
## 10.8.0 (YYYY-MM-DD)

### Enhancements
* [RealmApp] `ErrorCode.INVALID_EMAIL_PASSWORD` has been added, and is now thrown instead of `ErrorCode.SERVICE_UNKNOWN` when loggin in with the wrong credentials.
* `RealmQuery.rawPredicate()` now accepts a "BETWEEN" operator. Can be used like "age BETWEEN {20, 60}" which means "'Age' must be in the open interval ]20;60[".

* [RealmApp] Added `User.remove()` and `User.removeAsync()` that makes it possible to delete a user's Realm(s) from the device.

### Fixed
* [RealmApp] Crash when integrating a schema from the server with a `RealmAny` property to a Realm File that already had that property defined locally. ([Realm Core #4873](https://github.com/realm/realm-core/issues/4873), since 10.0.0)
* [RealmApp] Refreshing the access token after 30 minutes would fail silently, causing infinite retries every 10 seconds. This would also block opening Realms when opening an app with an already logged in user. (Issue [#7501](https://github.com/realm/realm-java/issues/7501), since 10.0.0)
* [RealmApp] Clarified Javadoc for `User.logOut()` and `User.logOutAsync()` as these methods do not delete a user's Realm(s).
* Build error when having cross module model references (Issue [#7474](https://github.com/realm/realm-java/issues/7474), since v10.4.0)

### Compatibility
* File format: Generates Realms with format v22. Unsynced Realms will be upgraded from Realm Java 2.0 and later. Synced Realms can only be read and upgraded if created with Realm Java v10.0.0-BETA.1.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
![Realm](logo.png)

[![Maven Central](https://img.shields.io/maven-central/v/io.realm/realm-gradle-plugin?colorB=4dc427&label=Maven%20Central)](https://search.maven.org/artifact/io.realm/realm-gradle-plugin)
[![License](https://img.shields.io/badge/License-Apache-blue.svg)](https://github.com/realm/realm-java/blob/master/LICENSE)

Realm is a mobile database that runs directly inside phones, tablets or wearables.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.realm.examples.appmodules.model;

import io.realm.RealmDictionary;
import io.realm.RealmList;
import io.realm.RealmObject;
import io.realm.RealmSet;
import io.realm.examples.librarymodules.model.Cat;
import io.realm.examples.librarymodules.model.EmbeddedAnimal;

// Not used by the app, but merely acts as sanity checks that we can make cross module references,
// and generate valid code for it.
public class CrossModuleLinks extends RealmObject {
public EmbeddedAnimal embeded;
public Cat link;
public RealmList<Cat> list;
public RealmSet<Cat> set;
public RealmDictionary<Cat> dictionary;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.realm.examples.librarymodules.model;

import io.realm.RealmObject;
import io.realm.annotations.RealmClass;

// Not used by the app, but merely acts as sanity checks that we can make cross module references,
// and generate valid code for it.
@RealmClass(embedded = true)
public class EmbeddedAnimal extends RealmObject {
public String name;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package io.realm.processor

import com.squareup.javawriter.JavaWriter
import io.realm.processor.Utils.fieldTypeHasPrimaryKey
import io.realm.processor.Utils.getGenericType
import io.realm.processor.ext.beginMethod
import io.realm.processor.ext.beginType
import java.io.BufferedWriter
Expand Down Expand Up @@ -456,8 +458,7 @@ class RealmProxyClassGenerator(private val processingEnvironment: ProcessingEnvi
emitStatement("%s.updateEmbeddedObject(realm, value, proxyObject, new HashMap<RealmModel, RealmObjectProxy>(), Collections.EMPTY_SET)", linkedProxyClass)
emitStatement("value = proxyObject")
} else {
val linkedMetadata = classCollection.getClassFromQualifiedName(linkedQualifiedClassName)
if (linkedMetadata.hasPrimaryKey()) {
if (fieldTypeHasPrimaryKey(field.asType(), classCollection)) {
emitStatement("value = realm.copyToRealmOrUpdate(value)")
} else {
emitStatement("value = realm.copyToRealm(value)")
Expand Down Expand Up @@ -802,8 +803,9 @@ class RealmProxyClassGenerator(private val processingEnvironment: ProcessingEnvi
beginControlFlow("if (item == null || RealmObject.isManaged(item))")
emitStatement("value.add(item)")
nextControlFlow("else")
val genericTypeMetadata = classCollection.getClassFromQualifiedName(genericType!!)
if (genericTypeMetadata.hasPrimaryKey()) {
val type = getGenericType(field) ?:
throw IllegalArgumentException("Unable to derive generic type of ${fieldName}")
if (fieldTypeHasPrimaryKey(type, classCollection)) {
emitStatement("value.add(realm.copyToRealmOrUpdate(item))")
} else {
emitStatement("value.add(realm.copyToRealm(item))");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.realm.processor

import com.sun.tools.javac.code.Attribute
import com.sun.tools.javac.code.Scope
import com.sun.tools.javac.code.Symbol
import com.sun.tools.javac.code.Type
import com.sun.tools.javac.util.Pair
Expand All @@ -37,6 +37,17 @@ import javax.tools.Diagnostic
*/
object Utils {

// API for retrieving symbols differs between JDK 8 and 9, so retrieve symbol information by
// reflection
private val classSymbolMembersMethod = Symbol.ClassSymbol::class.java.getMethod("members")
private val scopeElementsMethod = try {
// JDK 8
Scope::class.java.getMethod("getElements")
} catch (e: NoSuchMethodException) {
// JDK 9+
Scope::class.java.getMethod("getSymbols")
}

private lateinit var typeUtils: Types
private lateinit var messager: Messager
private lateinit var realmInteger: TypeMirror
Expand Down Expand Up @@ -667,4 +678,30 @@ object Utils {

return isEmbedded
}

// Returns whether a type has primary key field
// For types which are part of this processing round we can look it up immediately from
// the metadata in the `classCollection`. For types defined in other modules we will
// have to use the slower approach of inspecting the variable member `embedded` property of the
// RealmClass annotation using the compiler tool api.
fun fieldTypeHasPrimaryKey(type: TypeMirror, classCollection: ClassCollection): Boolean {
val fieldType = QualifiedClassName(type)
val fieldTypeMetaData: ClassMetaData? =
classCollection.getClassFromQualifiedNameOrNull(fieldType)
return fieldTypeMetaData?.hasPrimaryKey() ?: type.hasPrimaryKey()
}

private fun TypeMirror.hasPrimaryKey(): Boolean {
if (this is Type.ClassType) {
val scope = classSymbolMembersMethod.invoke(tsym)
val elements: Iterable<Symbol> = scopeElementsMethod.invoke(scope) as Iterable<Symbol>
val symbols = elements.filter { it is Symbol.VarSymbol }
return symbols.any {
it.declarationAttributes.any { attribute ->
attribute.type.tsym.qualifiedName.toString() == "io.realm.annotations.PrimaryKey"
}
}
}
return false
}
}
Loading

0 comments on commit db6b3e3

Please sign in to comment.