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

Entity property named as default is not working #1113

Closed
freddie1129 opened this issue Feb 9, 2023 · 4 comments
Closed

Entity property named as default is not working #1113

freddie1129 opened this issue Feb 9, 2023 · 4 comments
Labels
documentation Improvements or additions to documentation

Comments

@freddie1129
Copy link

freddie1129 commented Feb 9, 2023

Description

If the entity property is named as default as String type, the property value cannot be saved into box.
We can use put operation to save the entity into box, but the value of the property named as default is always empty.

For example, if we define an entity as below

@Entity 
data class Note(
  @Id var id: Long = 0,
  var default: String? = null,
)

The value of the property default will always blank when read it from box, even though this property has non-blank value when written into the box.

Basic info

  • ObjectBox version: 3.2.1, 3.5.1, just test these two version
  • Reproducibility: Yes
  • Device: [SAMSUNG SM-T630]
  • OS: [e.g. Android 12]

To Reproduce
Simply change the property text's name to default in the example project to reproduce it.
https://github.com/objectbox/objectbox-examples/blob/main/android-app-kotlin/src/main/java/io/objectbox/example/kotlin/Note.kt

@freddie1129 freddie1129 added the bug Something isn't working label Feb 9, 2023
@greenrobot-team
Copy link
Member

greenrobot-team commented Feb 13, 2023

See #879 for a discussion on this.

A workaround is to use a name allowed in Java, and if required, add @NameInDb("default").

We should probably at least document this (e.g. in Getting Started).

@greenrobot-team greenrobot-team added more info required Further information is requested documentation Improvements or additions to documentation and removed bug Something isn't working labels Feb 13, 2023
@freddie1129
Copy link
Author

Thanks, team.

It is reasonable that reserved keywords are not allowed. I also looked at #879, seems throwing out an error is impossible.
If that, please document it.
Thanks.

@greenrobot-team
Copy link
Member

Re-opening until this is documented.

@greenrobot-team greenrobot-team removed the more info required Further information is requested label Feb 14, 2023
@greenrobot-team
Copy link
Member

Added a note to https://docs.objectbox.io/getting-started#define-entity-classes.

Side-note: this probably can be solved in the future by using Kotlin Symbol Processing (#1075).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants