Skip to content

Commit

Permalink
The check to see if a row type doesn't need to be generated also need…
Browse files Browse the repository at this point in the history
…s to consider the primary key.
  • Loading branch information
broneill committed Jan 16, 2025
1 parent d4946c9 commit 6ae8bd6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/java/org/cojen/tupl/table/CommonRowTypeMaker.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,29 @@ private static Class<Row> doMakeFor(Class<?>... rowTypes) {
return Row.class;
}

// If all rowTypes are the same, and it implements Row, just use that.
// If all rowTypes are the same, and it implements Row, and it has a primary key
// consisting of all columns, just use that.
sameCheck: {
Class<?> rowType = rowTypes[0];

if (!Row.class.isAssignableFrom(rowType)) {
break sameCheck;
}

for (int i=1; i<rowTypes.length; i++) {
if (rowTypes[i] != rowType) {
break sameCheck;
}
}

try {
if (!RowInfo.find(rowType).valueColumns.isEmpty()) {
break sameCheck;
}
} catch (IllegalArgumentException e) {
break sameCheck;
}

return (Class<Row>) rowType;
}

Expand Down

0 comments on commit 6ae8bd6

Please sign in to comment.