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 association with a model has custom type primary key #368

Closed
sakuna63 opened this issue Jan 23, 2017 · 3 comments
Closed

Support association with a model has custom type primary key #368

sakuna63 opened this issue Jan 23, 2017 · 3 comments

Comments

@sakuna63
Copy link

Example:

If we have following model definitions

@Table
class Parent {
    @PrimaryKey
    public CustomKey customKey;
}

@Table
class Child {
    @PrimaryKey
    public long id;

    @Column
    Parent parent;
}

class CustomKey {
    // ...
}

@StaticTypeAdapter(targetType = CustomKey.class, serializedType = String.class)
class CustomeKeyAdapter {
    // ...
}

Generated AssociationDef should use serialized customKey by CustomeKeyAdapter, but actually it attempts to use raw customeKey like a below

class Child_Scheme {
    // ...
    public final AssociationDef<Child, Parent, Parent_Schema> parent;

    this.parent = new AssociationDef<Child, Parent, Parent_Schema> ... {
        // ...
      @NonNull
      @Override
      public String getSerialized(@NonNull Child model) {
          return model.parnet.customKey; // customKey should be serialized here by CustomeKeyAdpater!!!
      }
    // ...
    };
}

Whould you have any plan to support this feature?
Thanks.

@gfx
Copy link
Member

gfx commented Jan 25, 2017

This is definitely a bug around type adapters. I'm working in progress on it in #370.

@gfx gfx closed this as completed in #370 Jan 25, 2017
@sakuna63
Copy link
Author

Thanks!! 🙏

@gfx
Copy link
Member

gfx commented Jan 25, 2017

Released v4.1.1 including this fix. Thanks for the report! 🎆

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