Skip to content

Commit

Permalink
Modify toQueryString to chunk large list of ConditionParam
Browse files Browse the repository at this point in the history
  • Loading branch information
LZRS committed Jun 12, 2024
1 parent 1016558 commit 6b3d4c4
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2023 Google LLC
* Copyright 2021-2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -86,15 +86,18 @@ internal sealed class FilterCriteria(
* intended.
*/
private fun List<ConditionParam<*>>.toQueryString(operation: Operation) =
this.joinToString(
separator = " ${operation.logicalOperator} ",
prefix = if (size > 1) "(" else "",
postfix = if (size > 1) ")" else "",
) {
if (it.params.size > 1) {
"(${it.condition})"
} else {
it.condition
this.chunked(50) { conditionParams ->
conditionParams.joinToString(
separator = " ${operation.logicalOperator} ",
prefix = if (size > 1) "(" else "",
postfix = if (size > 1) ")" else "",
) {
if (it.params.size > 1) {
"(${it.condition})"
} else {
it.condition
}
}
}
}
.joinToString(separator = " ${operation.logicalOperator} ")
}

0 comments on commit 6b3d4c4

Please sign in to comment.