Add enum and number values support to JsonKeysetCursorStrategy#1346
Conversation
Signed-off-by: Ilya Bakaev <stupid58fly@gmail.com>
|
Hello @stupid58fly We're considering both this issue and #1347. Could you first elaborate a bit on the exact problem you're seeing? How do your entities/repositories/data fetchers look like in your code and what error are you hitting exactly? We don't need a complete analysis of the problem, but rather a short sample or anything that can help us better understand the use case would be welcome. |
i have @Entity
@Table(name = "product")
public class Product {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String name;
@Column(nullable = false)
private BigDecimal cost;
}public interface ProductRepository extends JpaRepository<Product, Long> {
Window<Product> findByIdIsNotNull(ScrollPosition position, Sort sort, Limit limit);
}@Controller
@RequiredArgsConstructor
public class ProductController {
private final ProductRepository productRepository;
@QueryMapping
public Window<Product> products(ScrollSubrange scrollSubrange) {
var position = scrollSubrange.position().orElseGet(ScrollPosition::keyset);
var sort = Sort.by(Sort.Direction.ASC, "cost");
var limit = scrollSubrange.count().stream().boxed().findFirst().map(Limit::of).orElseGet(Limit::unlimited);
return productRepository.findByIdIsNotNull(position, sort, limit);
}
}when i try to fetch products without parameters, all is ok query MyQuery {
products (
after: "S19bImphdmEudXRpbC5Db2xsZWN0aW9ucyRVbm1vZGlmaWFibGVNYXAiLHsiaWQiOlsiamF2YS5sYW5nLkxvbmciLDIwXSwiY29zdCI6WyJqYXZhLm1hdGguQmlnRGVjaW1hbCIsMC4wMF19XQ=="
first: 10
) {
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
}
edges {
cursor
node {
cost
id
name
}
}
}
}and this PR will fix the issue with deserialization for number (long, big decimal, etc) and enums the issue #1347 is aimed for a more general fix, i.e. for |
|
Hi @bclozel, |
This commit adds JSON serialization support for Java Enums and Number types in keyset cursors. See gh-1346 Signed-off-by: Ilya Bakaev <stupid58fly@gmail.com>
|
Thanks for your contribution @stupid58fly , this is now merged in main and will be released this month. |
same issue as at #1327 for enum and numeric values exept integer and double