You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/02/24 08:59:12 UTC

[GitHub] [flink] dawidwys commented on a change in pull request #11070: [FLINK-16013][core] Make complex type config options could be parsed correctly

dawidwys commented on a change in pull request #11070: [FLINK-16013][core] Make complex type config options could be parsed correctly
URL: https://github.com/apache/flink/pull/11070#discussion_r383129131
 
 

 ##########
 File path: flink-core/src/main/java/org/apache/flink/configuration/StructuredOptionsSplitter.java
 ##########
 @@ -52,6 +59,37 @@
 		return processTokens(tokens);
 	}
 
+	/**
+	 * When write a string out, it is always needs to escaped. If the input string contains double quote or specified
+	 * escape chars, then it will be escaped by single quote. The single quote will be escaped by doubling.
+	 *
+	 * <p>Given that the escapeChar is (;)
+	 *
+	 * <p>Examples:
+	 * <ul>
+	 *     <li>A,B,C,D => A,B,C,D</li>
+	 *     <li>A;BCD => 'A;BCD'</li>
+	 *     <li>AB"C"D => 'AB"C"D'</li>
+	 *     <li>AB'"D:B => 'AB''"D:B'</li>
+	 * </ul>
+	 *
+	 * @param value a string which needs to be escaped
+	 * @param escapeChars escape chars for the escape conditions
+	 * @return escaped string with single quote
+	 */
+	static String escapeWithSingleQuote(String value, String... escapeChars) {
 
 Review comment:
   I don't necessarily understand why do we need that complex logic. 
   Can't we just do `"'" + value.replaceAll("'", "''") + "'"` ?
   
   Moreover we should try not to use any external dependencies. Especially guava.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services