Skip to content

Commit

Permalink
Fix JDBC constant rewrites for NULL literal
Browse files Browse the repository at this point in the history
  • Loading branch information
wendigo authored and findepi committed Jul 29, 2022
1 parent f1122d3 commit 2c5ce56
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public Pattern<Constant> getPattern()
@Override
public Optional<String> rewrite(Constant constant, Captures captures, RewriteContext<String> context)
{
if (constant.getValue() == null) {
return Optional.empty();
}

Type type = constant.getType();
if (constant.getValue() == null) {
return Optional.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public Optional<String> rewrite(Constant constant, Captures captures, RewriteCon
return Optional.empty();
}
Slice slice = (Slice) constant.getValue();
if (slice == null) {
return Optional.empty();
}
return Optional.of("'" + slice.toStringUtf8().replace("'", "''") + "'");
}
}

0 comments on commit 2c5ce56

Please sign in to comment.