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

Support annotations for getter/setter properties #392

Closed
khainke opened this issue Mar 3, 2022 · 4 comments
Closed

Support annotations for getter/setter properties #392

khainke opened this issue Mar 3, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@khainke
Copy link

khainke commented Mar 3, 2022

Currently, the @Property Annotation is only available for fields, that are defined as such in the @entity.

Describe the solution you'd like

It would be nice to be able to add the @Property Annotation also to a getter (assuming a matching setter exists). This would just have the same effect on the property defined by the getter / setter pair as if it would have, would the annotation be attached to an equivalent field.

@khainke khainke added the enhancement New feature or request label Mar 3, 2022
@greenrobot-team
Copy link
Member

greenrobot-team commented Mar 8, 2022

Thanks! It's odd that this doesn't work already. Also @Transient on a getter does not appear to get recognized.

Edit: an internal issue for this exists.

@greenrobot-team greenrobot-team self-assigned this Jul 5, 2022
@greenrobot-team greenrobot-team changed the title @Property Annotation for getter/setter properties Support annotations for getter/setter properties Apr 18, 2023
@greenrobot-team
Copy link
Member

Same for @Index, reported originally in #528.

@greenrobot-team
Copy link
Member

Also freezed classes with non-required properties are affected by this, see #565.

greenrobot-team added a commit that referenced this issue Feb 12, 2024
Support annotations on getters

See merge request objectbox/objectbox-dart!69
@greenrobot-team greenrobot-team added this to the 2.4.1 milestone Feb 12, 2024
@greenrobot-team
Copy link
Member

Annotating getters will be possible with the next release.

You will be able to do something like this:

@Property(type: PropertyType.date)
@Index()
DateTime get date => TODO;
set date(DateTime value) => TODO;

@Transient()
int get computedValue => TODO;
set computedValue(int value) => TODO;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants