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

[firestore_serialize] getters can't be ignored #40

Open
ciriousjoker opened this issue Aug 31, 2020 · 4 comments
Open

[firestore_serialize] getters can't be ignored #40

ciriousjoker opened this issue Aug 31, 2020 · 4 comments

Comments

@ciriousjoker
Copy link
Contributor

Example code:

@FirestoreDocument()
class MyModel {
  DocumentReference selfRef;

  String id;
  String label;

  MyModel({
    this.selfRef,
    this.id,
    this.label,
  });
  bool operator ==(o) => o is MyModel && id == o.id;

  @override
  @FirestoreAttribute(ignore: true)
  int get hashCode => id.hashCode;
}

hashCode still makes it into the serialized map :(

Workaround:

  Map<String, dynamic> toMap() {
    Map ret = _$myModelToMap(this);
    ret.remove("hashCode");
    return ret;
  }
@ciriousjoker ciriousjoker changed the title getters can't be ignored [firestore_serialize] getters can't be ignored Aug 31, 2020
@ciriousjoker
Copy link
Contributor Author

ciriousjoker commented Oct 23, 2020

This seems to be fixed in my fork of it. However, I don't know if this was because of this library or because I updated all the dependencies.

I replaced displayName (deprecated) with element.name, which might differentiate between getters and normal variables automatically.

EDIT: Nevermind, getters are still detected as regular variables, but they only apply to the toMap() functions

@lukas-h
Copy link
Member

lukas-h commented Oct 24, 2020

Please create a pull request

@ciriousjoker
Copy link
Contributor Author

Like I said, the test case has been broken by it and this issue is untouched. Should I still make the PR?

@lukas-h
Copy link
Member

lukas-h commented Oct 25, 2020

Yes, we can still work on it the PR until it‘s merged

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

No branches or pull requests

2 participants