Skip to content

Commit 92c593e

Browse files
Merge pull request #1179 from tianlu-root/master
fix: Function names are default uppercase
2 parents a147fc6 + b5a6d68 commit 92c593e

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Datart
3+
* <p>
4+
* Copyright 2021
5+
* <p>
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
* <p>
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* <p>
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package datart.core.common;
20+
21+
import org.apache.ibatis.javassist.ClassPool;
22+
import org.apache.ibatis.javassist.CtClass;
23+
import org.apache.ibatis.javassist.CtMethod;
24+
25+
public class ClassTransformer {
26+
27+
public static void transform() {
28+
transformSqlWriter();
29+
transformFlyway();
30+
}
31+
32+
private static void transformSqlWriter() {
33+
try {
34+
ClassPool classPool = ClassPool.getDefault();
35+
CtClass ctClass = classPool.get("org.apache.calcite.sql.pretty.SqlPrettyWriter");
36+
CtMethod keyword = ctClass.getDeclaredMethod("keyword");
37+
keyword.setBody("{ maybeWhitespace($1);" +
38+
" buf.append($1);" +
39+
" if (!$1.equals(\"\")) {" +
40+
" setNeedWhitespace(needWhitespaceAfter($1));" +
41+
" } " +
42+
"return;} ");
43+
ctClass.toClass();
44+
} catch (Exception e) {
45+
e.printStackTrace();
46+
}
47+
}
48+
49+
private static void transformFlyway() {
50+
try {
51+
ClassPool classPool = ClassPool.getDefault();
52+
CtClass ctClass = classPool.get("org.flywaydb.core.internal.database.mysql.MySQLConnection");
53+
CtMethod getIntVariableValue = ctClass.getDeclaredMethod("getIntVariableValue");
54+
getIntVariableValue.setBody("return 0;");
55+
56+
CtMethod doRestoreOriginalState = ctClass.getDeclaredMethod("doRestoreOriginalState");
57+
doRestoreOriginalState.setBody("return;");
58+
59+
CtMethod hasUserVariableResetCapability = ctClass.getDeclaredMethod("hasUserVariableResetCapability");
60+
hasUserVariableResetCapability.setBody("{return false;}");
61+
ctClass.toClass();
62+
} catch (Exception e) {
63+
e.printStackTrace();
64+
}
65+
}
66+
}

server/src/main/java/datart/DatartServerApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package datart;
22

33

4+
import datart.core.common.ClassTransformer;
45
import org.springframework.boot.SpringApplication;
56
import org.springframework.boot.autoconfigure.SpringBootApplication;
67

78
@SpringBootApplication(scanBasePackages = {"datart"})
89
public class DatartServerApplication {
910

1011
public static void main(String[] args) {
12+
ClassTransformer.transform();
1113
SpringApplication.run(DatartServerApplication.class, args);
1214
}
1315

0 commit comments

Comments
 (0)