diff --git a/src/main/java/sirius/db/es/ElasticQuery.java b/src/main/java/sirius/db/es/ElasticQuery.java index 85847b2b..915f5374 100644 --- a/src/main/java/sirius/db/es/ElasticQuery.java +++ b/src/main/java/sirius/db/es/ElasticQuery.java @@ -50,6 +50,15 @@ * @param the type of entities to be queried */ public class ElasticQuery extends Query, E, ElasticConstraint> { + + /** + * Defines the fallback value used when no last sort value is present. + * + * @see #searchAfter(String) + * @see #getLastSortValue() + */ + public static final String NO_LAST_SORT_VALUE = "-"; + /** * If we only fetch from a single shard (as we use a routing), we fetch up to {@link #BLOCK_SIZE_FOR_SINGLE_SHARD} * entities at once and hope to process them within {@link #STREAM_BLOCKWISE_PIT_TTL}. @@ -448,15 +457,15 @@ public ElasticQuery searchAfter(List searchAfter) { * Sets a singular "last sort value" to continue a previous query. *

* It is recommended to sort by {@link ElasticEntity#ID} when using this. Note that this gracefully - * handles empty values as well as "-" which is properly generated by {@link #getLastSortValue()} if no more - * results are expected. + * handles empty values as well as {@link #NO_LAST_SORT_VALUE} which is properly generated by {@link #getLastSortValue()} + * if no more results are expected. * * @param searchAfter the last sort value of the previous result * @return the query itself for fluent method calls */ public ElasticQuery searchAfter(String searchAfter) { if (Strings.isFilled(searchAfter)) { - if ("-".equals(searchAfter)) { + if (NO_LAST_SORT_VALUE.equals(searchAfter)) { return this.fail(); } @@ -494,17 +503,17 @@ public List getLastSortValues() { /** * Obtains the last sort value of this result. *

- * Note that this will automatically return "-" if no more results are expected. Use this in conjunction with - * {@link #searchAfter(String)} and sort queries by {@link ElasticEntity#ID}. + * Note that this will automatically return {@link #NO_LAST_SORT_VALUE} if no more results are expected. + * Use this in conjunction with {@link #searchAfter(String)} and sort queries by {@link ElasticEntity#ID}. * * @return the last sort value within this result */ public String getLastSortValue() { if (limit > 0 && Json.getArrayAt(getRawResponse(), HITS_POINTER).size() < limit) { - return "-"; + return NO_LAST_SORT_VALUE; } - return getLastSortValues().stream().filter(Strings::isFilled).findFirst().orElse("-"); + return getLastSortValues().stream().filter(Strings::isFilled).findFirst().orElse(NO_LAST_SORT_VALUE); } /** diff --git a/src/main/java/sirius/db/mixing/annotations/Length.java b/src/main/java/sirius/db/mixing/annotations/Length.java index cbf7d318..84523820 100644 --- a/src/main/java/sirius/db/mixing/annotations/Length.java +++ b/src/main/java/sirius/db/mixing/annotations/Length.java @@ -16,6 +16,12 @@ /** * Specifies the column length, most probably of string (CHAR) columns. + *

+ * This annotation has no effect on properties other than a string, except the columns + * definitions for Clickhouse, where the length is used also for other types, for example int, + * to define the int size to use. + * + * @see sirius.db.jdbc.schema.ClickhouseDatabaseDialect */ @Documented @Retention(RetentionPolicy.RUNTIME)