jdbi icon indicating copy to clipboard operation
jdbi copied to clipboard

Update documenation examples to use multi-line strings.

Open vab2048 opened this issue 2 months ago • 2 comments

I have just come across JDBI and reading through the doucmentation saw examples like this, escaping quotes:

List<User> users = jdbi.withHandle(handle -> {
    handle.execute("CREATE TABLE \"user\" (id INTEGER PRIMARY KEY, \"name\" VARCHAR)");

Since you are now moving to a Java 17 baseline these can be replaced with multi-line strings/text blocks which would make the SQL string like this:

List<User> users = jdbi.withHandle(handle -> {
    handle.execute("""
      CREATE TABLE "user" (id INTEGER PRIMARY KEY, "name" VARCHAR)""");

I think even though it adds an extra line, it is clearer. Would you be amenable to me raising a PR changing all instances of strings containing escaped quotes to multi-line strings?

vab2048 avatar Oct 07 '25 19:10 vab2048

Yes, that sounds like a good idea to me! Thank you

stevenschlansker avatar Oct 07 '25 21:10 stevenschlansker

Getting a PR would be great, thank you! We might hold off merging till we actually moved to 17. If we need to push another 3.49 release, then we would have to undo.

hgschmie avatar Oct 09 '25 00:10 hgschmie