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

columnName of ForeignKeyReference is not used for PrimaryKey #1504

Closed
Devenias opened this issue Dec 27, 2017 · 2 comments
Closed

columnName of ForeignKeyReference is not used for PrimaryKey #1504

Devenias opened this issue Dec 27, 2017 · 2 comments
Labels
Milestone

Comments

@Devenias
Copy link

DBFlow Version: 4.2.3

Hi, I just upgraded from an older version to v4.2.3 and have an issue with the code generation. I could reproduce it in a sample project as well.

Here are some classes which are referenced by a ForeignKey (which is also a PrimaryKey) and the column is renamed in ForeigKeyReference

@Table(database = AppDatabase.class)
public class AntHill extends BaseModel {
    @PrimaryKey
    public String hillId;
}

@Table(database = AppDatabase.class)
public class Ants extends BaseModel {
    @PrimaryKey
    public String antId;

    @PrimaryKey
    @ForeignKey(tableClass = AntHill.class, references = {
            @ForeignKeyReference(columnName = "hillIdRef", foreignKeyColumnName = "hillId")
    })
    public String hillId;
}

The Project won't compile as it is because there is an error in the Ants_Table.java.
error: cannot find symbol variable hillId
Caused by that generated method in the Ants_Table.java:

@Override
public final OperatorGroup getPrimaryConditionClause(Ants model) {
  OperatorGroup clause = OperatorGroup.clause();
  clause.and(antId.eq(model.antId));
  clause.and(hillId.eq(model.hillId));
  return clause;
}

It should be clause.and(hillIdRef.eq(model.hillId)); if I'm not wrong.

@agrosner
Copy link
Owner

ill look into it. thanks for report!

@agrosner agrosner added this to the 4.2.4 milestone Dec 28, 2017
@agrosner agrosner added the bug label Dec 28, 2017
@agrosner
Copy link
Owner

in develop for 4.2.4. you can try it via 904a66738e

@agrosner agrosner mentioned this issue Dec 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants