Skip to content

Commit

Permalink
- FIX: Fixed issue caused by previous commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-raubach committed Apr 28, 2021
1 parent 7ebc080 commit 3a3ccb3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ apply plugin: 'com.bmuschko.cargo-base'
compileJava.options.encoding = 'UTF-8'

group 'uk.ac.hutton.germinate'
version '4.1.4'
version '4.1.5'

sourceCompatibility = 1.8

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ default <T extends Record> void filter(SelectJoinStep<T> step, Filter[] filters,

default Condition filterIndividual(Filter filter, boolean jsonOperationAllowed)
{
Field<Object> field = DSL.field("{0}", filter.getSafeColumn());
Field<Object> field = DSL.field(filter.getSafeColumn());
List<String> values = new ArrayList<>();

if (!CollectionUtils.isEmpty(filter.getValues()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import jhi.germinate.resource.*;
import jhi.germinate.server.Database;
import jhi.germinate.server.util.StringUtils;

/**
* @author Sebastian Raubach
Expand Down Expand Up @@ -101,14 +102,25 @@ protected <T extends Record> SelectForUpdateStep<T> setPaginationAndOrderBy(Sele
if (ascending != null && orderBy != null)
{
if (ascending)
step.orderBy(DSL.field("{0}", orderBy).asc());
step.orderBy(DSL.field(getSafeColumn(orderBy)).asc());
else
step.orderBy(DSL.field("{0}", orderBy).desc());
step.orderBy(DSL.field(getSafeColumn(orderBy)).desc());
}

return step.limit(pageSize)
.offset(pageSize * currentPage);
}

protected static String getSafeColumn(String column)
{
if (StringUtils.isEmpty(column))
{
return null;
}
else
{
return column.replaceAll("[^a-zA-Z0-9._-]", "").replaceAll("(.)(\\p{Upper})", "$1_$2").toLowerCase();
}
}

protected String getRequestAttributeAsString(String parameter)
Expand Down

0 comments on commit 3a3ccb3

Please sign in to comment.