diff --git a/mug-guava/src/main/java/com/google/mu/safesql/SafeSql.java b/mug-guava/src/main/java/com/google/mu/safesql/SafeSql.java index 80a2b6a3af..7b1e9401c7 100644 --- a/mug-guava/src/main/java/com/google/mu/safesql/SafeSql.java +++ b/mug-guava/src/main/java/com/google/mu/safesql/SafeSql.java @@ -150,12 +150,12 @@ * Sometimes you may wish to parameterize by table names, column names etc. * for which JDBC has no support. * - * If the identifiers can come from compile-time literals, you can wrap them using + *

If the identifiers are compile-time string literals, you can wrap them using * {@code SafeSql.of(COLUMN_NAME)}, which can then be composed as subqueries. - * - *

But what if the identifier string is loaded from a resource file, or is specified by a + * But what if the identifier string is loaded from a resource file, or is specified by a * request field? - *
Passing the string directly as a template parameter will only generate the JDBC + * + *

Passing the string directly as a template parameter will only generate the JDBC * '?' parameter in its place, which won't work (JDBC can't parameterize identifiers); * {@code SafeSql.of(theString)} will fail to compile because such strings are inherently * dynamic and untrusted. @@ -170,7 +170,9 @@ *

In the above example, if {@code getColumns()} returns {@code ["id", "age"]}, the genereated * SQL will be: * - *

{@code SELECT `id`, `age` FROM Users}
+ *
{@code
+ *   SELECT `id`, `age` FROM Users
+ * }
* *

That is, each individual string will be backtick-quoted and then joined by ", ". *