Skip to content

Commit

Permalink
ho-dev#2094 youth scout comment column length
Browse files Browse the repository at this point in the history
  • Loading branch information
wsbrenk committed Jun 26, 2024
1 parent 63144d3 commit d9a1a69
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/main/java/core/db/AbstractTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ public AbstractTable(String tableName, ConnectionManager connectionManager) {
* @return Truncated string
*/
static String truncateString(String s, int maxLength) {
if (s != null && s.length() > maxLength) return s.substring(0, maxLength);
if (s != null && s.length() > maxLength){
HOLogger.instance().warning(AbstractTable.class, "truncated string: " + s);
return s.substring(0, maxLength);
}
return s;
}

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/core/db/DBUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ private void updateDBv900(int dbVersion) throws SQLException {
var matchDetailsTable = dbManager.getTable(MatchDetailsTable.TABLENAME);
matchDetailsTable.tryChangeColumn("Matchreport", "VARCHAR(40000)");

var youthScoutCommentTable = dbManager.getTable(YouthScoutCommentTable.TABLENAME);
youthScoutCommentTable.tryChangeColumn("Text", "VARCHAR(1024)");

var playerTable = dbManager.getTable(SpielerTable.TABLENAME);
playerTable.tryAddColumn("SubForm", "FLOAT DEFAULT 0");

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/core/db/YouthScoutCommentTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected void initColumns() {
columns = new ColumnDescriptor[]{
ColumnDescriptor.Builder.newInstance().setColumnName("YOUTHPLAYER_ID").setGetter((p) -> ((ScoutComment) p).getYouthPlayerId()).setSetter((p, v) -> ((ScoutComment) p).setYouthPlayerId( (int) v)).setType(Types.INTEGER).isNullable(false).build(),
ColumnDescriptor.Builder.newInstance().setColumnName("INDEX").setGetter((p) -> ((ScoutComment) p).getIndex()).setSetter((p, v) -> ((ScoutComment) p).setIndex( (int) v)).setType(Types.INTEGER).isNullable(false).build(),
ColumnDescriptor.Builder.newInstance().setColumnName("Text").setGetter((p) -> ((ScoutComment) p).getText()).setSetter((p, v) -> ((ScoutComment) p).setText( (String) v)).setType(Types.VARCHAR).setLength(255).isNullable(true).build(),
ColumnDescriptor.Builder.newInstance().setColumnName("Text").setGetter((p) -> truncateString (((ScoutComment) p).getText(), 1024)).setSetter((p, v) -> ((ScoutComment) p).setText( (String) v)).setType(Types.VARCHAR).setLength(1024).isNullable(true).build(),
ColumnDescriptor.Builder.newInstance().setColumnName("Type").setGetter((p) -> ((ScoutComment) p).getType().getValue()).setSetter((p, v) -> ((ScoutComment) p).setType(CommentType.valueOf((Integer) v))).setType(Types.INTEGER).isNullable(true).build(),
ColumnDescriptor.Builder.newInstance().setColumnName("Variation").setGetter((p) -> ((ScoutComment) p).getVariation()).setSetter((p, v) -> ((ScoutComment) p).setVariation((Integer) v)).setType(Types.INTEGER).isNullable(true).build(),
ColumnDescriptor.Builder.newInstance().setColumnName("SkillType").setGetter((p) -> Skills.ScoutCommentSkillTypeID.value(((ScoutComment) p).getSkillType())).setSetter((p, v) -> ((ScoutComment) p).setSkillType(Skills.ScoutCommentSkillTypeID.valueOf((Integer) v))).setType(Types.INTEGER).isNullable(true).build(),
Expand Down

0 comments on commit d9a1a69

Please sign in to comment.