File tree Expand file tree Collapse file tree 3 files changed +29
-1
lines changed
main/java/org/springframework/data/jpa/datatables
test/java/org/springframework/data/jpa/datatables/repository Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ public class DataTablesInput {
3939 * negates any benefits of server-side processing!)
4040 */
4141@ NotNull
42- @ Min (0 )
42+ @ Min (- 1 )
4343private Integer length ;
4444
4545/**
Original file line number Diff line number Diff line change @@ -85,6 +85,10 @@ private Pageable getPageable(DataTablesInput input) {
8585}
8686Sort sort = orders .isEmpty () ? null : new Sort (orders );
8787
88+ if (input .getLength () == -1 ) {
89+ input .setStart (0 );
90+ input .setLength (Integer .MAX_VALUE );
91+ }
8892return new PageRequest (input .getStart () / input .getLength (),
8993input .getLength (), sort );
9094}
Original file line number Diff line number Diff line change @@ -266,6 +266,30 @@ public void testWithAdditionalSpecification() {
266266
267267}
268268
269+ @ Test
270+ public void testWithZeroLength () {
271+ DataTablesInput input = getBasicInput ();
272+
273+ input .setLength (0 );
274+ DataTablesOutput <User > output = userRepository .findAll (input );
275+ assertNotNull (output );
276+ assertNotNull (output .getError ());
277+ assertEquals (output .getError (),
278+ "java.lang.ArithmeticException: / by zero" );
279+ }
280+
281+ @ Test
282+ public void testWithNegativeLength () {
283+ DataTablesInput input = getBasicInput ();
284+
285+ input .setLength (-1 );
286+ DataTablesOutput <User > output = userRepository .findAll (input );
287+ assertNotNull (output );
288+ assertNull (output .getError ());
289+ assertEquals (24 , (long ) output .getRecordsFiltered ());
290+ assertEquals (24 , (long ) output .getRecordsTotal ());
291+ }
292+
269293/**
270294 *
271295 * @return basic input parameters
You can’t perform that action at this time.
0 commit comments