Skip to content

Commit

Permalink
@ContainerKey now respected on foreign column fields such that
Browse files Browse the repository at this point in the history
it references the whole object by that key
  • Loading branch information
Andrew Grosner committed Jul 3, 2015
1 parent 2bae8af commit 22a3281
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public void writeSaveDefinition(JavaWriter javaWriter, boolean isModelContainerA
javaWriter.emitStatement("ModelContainer %1s = %1s.getInstance(%1s.getValue(\"%1s\"), %1s.class)",
modelDefinition,
ModelUtils.getVariable(true), ModelUtils.getVariable(true),
columnFieldName,
containerKeyName,
foreignKeyTableClassName);
} else {
javaWriter.beginControlFlow("if (%1s != null)", modelDefinition);
Expand Down Expand Up @@ -458,11 +458,11 @@ public void writeLoadFromCursorDefinition(BaseTableDefinition tableDefinition, J

if (isModelContainerAdapter && isModel) {
javaWriter.emitStatement("%1s.put(\"%1s\",%1s.getData())", ModelUtils.getVariable(true),
columnFieldName, modelContainerName);
containerKeyName, modelContainerName);
javaWriter.nextControlFlow("else");

javaWriter.emitStatement("%1s.put(\"%1s\", null)", ModelUtils.getVariable(true),
columnFieldName);
containerKeyName);
}

javaWriter.endControlFlow();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.raizlabs.android.dbflow.test;

import com.raizlabs.android.dbflow.annotation.Column;
import com.raizlabs.android.dbflow.annotation.ContainerKey;
import com.raizlabs.android.dbflow.annotation.ForeignKey;
import com.raizlabs.android.dbflow.annotation.ForeignKeyReference;
import com.raizlabs.android.dbflow.annotation.ModelContainer;
Expand Down Expand Up @@ -37,6 +38,7 @@ public interface Columns {
@Column(name = Columns.AQL_TIMESTAMP)
private Date timestamp;

@ContainerKey("boxedLodo")
@Column
@ForeignKey(references = {@ForeignKeyReference(columnName = "id1", columnType = long.class, foreignColumnName = "id"),
@ForeignKeyReference(columnName = "id2", columnType = String.class, foreignColumnName = "name")})
Expand Down

0 comments on commit 22a3281

Please sign in to comment.