Unverified Commit ed1e6951 authored by Licho's avatar Licho Committed by GitHub

fix: double slop (#3063)

parent 65b71948
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
<component name="IssueNavigationConfiguration"> <component name="IssueNavigationConfiguration">
<option name="links"> <option name="links">
<list> <list>
...@@ -13,4 +10,8 @@ ...@@ -13,4 +10,8 @@
</list> </list>
</option> </option>
</component> </component>
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project> </project>
\ No newline at end of file
...@@ -47,7 +47,14 @@ public class SqlUtilTest { ...@@ -47,7 +47,14 @@ public class SqlUtilTest {
String removedNoteSql = SqlUtil.removeNote(testSql); String removedNoteSql = SqlUtil.removeNote(testSql);
Assertions.assertThat(removedNoteSql).isNotNull(); Assertions.assertThat(removedNoteSql).isNotNull();
Assertions.assertThat(removedNoteSql).isNotEqualTo(testSql); Assertions.assertThat(removedNoteSql)
.isEqualTo("//test2\n" + "\n"
+ "\n"
+ "select 1 \n"
+ " from test # test9\n"
+ " where '1' <> '-- ::.' //test6\n"
+ " and 1=1 \n"
+ " and 'zz' <> null;");
} }
@Test @Test
......
...@@ -60,7 +60,7 @@ public class SqlUtil { ...@@ -60,7 +60,7 @@ public class SqlUtil {
// Remove the special-space characters // Remove the special-space characters
sql = sql.replaceAll("\u00A0", " ").replaceAll("[\r\n]+", "\n"); sql = sql.replaceAll("\u00A0", " ").replaceAll("[\r\n]+", "\n");
// Remove annotations Support '--aa' , '/**aaa*/' , '//aa' , '#aaa' // Remove annotations Support '--aa' , '/**aaa*/' , '//aa' , '#aaa'
Pattern p = Pattern.compile("(?ms)('(?:''|[^'])*')|--.*?$|//.*?$|/\\*[^+].*?\\*/|#.*?$|"); Pattern p = Pattern.compile("(?ms)('(?:''|[^'])*')|--.*?$|/\\*[^+].*?\\*/|");
String presult = p.matcher(sql).replaceAll("$1"); String presult = p.matcher(sql).replaceAll("$1");
return presult.trim(); return presult.trim();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment