Skip to content

Commit

Permalink
feat(null): upsert and onConflict. Fix bad syntax in queryParams For …
Browse files Browse the repository at this point in the history
…upserts

Issues :
- #3 Upsert does not really upsert
- #8 add on_conflict for upsert
  • Loading branch information
julienTho committed Jul 25, 2024
1 parent 4bc22b8 commit 316573f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,4 @@ private URI getUri(String resource, Map<String, List<String>> params) {
return uriBuilder.build().encode().toUri();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ public BulkResponse<T> upsert(List<Object> values, BulkOptions options) {
* @return map of query params for on conflict if annotation OnConflict is present otherwise empty map
*/
private Map<String, List<String>> getUpsertQueryParams() {
return Optional.ofNullable(this.getClass().getAnnotation(OnConflict.class))
.map(OnConflict::columnNames)
.map(Arrays::asList)
.map(onConflictList-> Map.of(ON_CONFLICT_QUERY_PARAMS, onConflictList))
.orElse(Map.of());
OnConflict onConflict = this.getClass().getAnnotation(OnConflict.class);
if (Objects.nonNull(onConflict)) {
return Map.of(ON_CONFLICT_QUERY_PARAMS, List.of(String.join(",", onConflict.columnNames())));
}
return Collections.emptyMap();
}

/**
Expand Down

0 comments on commit 316573f

Please sign in to comment.