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 (#39)

Issues :
- #3 Upsert does not really upsert
- #8 add on_conflict for upsert

Co-authored-by: jthoreux <[email protected]>
  • Loading branch information
arnaud-thorel-of and julienTho authored Jul 25, 2024
1 parent 4bc22b8 commit 6f20b50
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 6f20b50

Please sign in to comment.