Skip to content

Commit

Permalink
Add insert object and insert jsonb classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablo Collins committed May 18, 2020
1 parent 7a66580 commit f089bff
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
16 changes: 16 additions & 0 deletions gumdrop.sql/gumdrop/sql/InsertJsonbColumn.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package gumdrop.sql;

import java.util.function.Function;

public class InsertJsonbColumn<T> extends InsertObjectColumn<T> {

public InsertJsonbColumn(String name, Function<T, Object> getter) {
super(name, getter);
}

@Override
public void appendBind(StringBuilder bind) {
bind.append("to_jsonb(?::jsonb)");
}

}
18 changes: 18 additions & 0 deletions gumdrop.sql/gumdrop/sql/InsertObjectColumn.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package gumdrop.sql;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.function.Function;

public class InsertObjectColumn<T> extends InsertColumn<T, Object> {

public InsertObjectColumn(String name, Function<T, Object> getter) {
super(name, getter);
}

@Override
public void set(PreparedStatement ps, int idx, Object o) throws SQLException {
ps.setObject(idx, o);
}

}
3 changes: 1 addition & 2 deletions gumdrop.web/gumdrop/web/controller/SessionController.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,10 @@ private HttpResponse createResponse(HttpResponseHeader responseHeader) {
HttpResponse response = new HttpResponse(responseHeader);
if (isAuthorized()) {
process(response);
return response;
} else {
HeaderUtil.setRedirectHeaders(responseHeader, getUnauthorizedPath());
return response;
}
return response;
}

private static String createSessionId(HttpResponseHeader responseHeader) {
Expand Down

0 comments on commit f089bff

Please sign in to comment.