Skip to content

Commit fc44cd8

Browse files
committed
2025-12-07 zhengkai 修复对primary key的处理
1 parent 67185ad commit fc44cd8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/main/java/com/softdev/system/generator/service/impl/parser/SqlParserServiceImpl.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ public ClassInfo processTableIntoClassInfo(ParamInfo paramInfo) throws Exception
305305
// 2019-2-22 zhengkai 要在条件中使用复杂的表达式
306306
// 2019-4-29 zhengkai 优化对普通和特殊storage关键字的判断(感谢@AhHeadFloating的反馈 )
307307
// 2020-10-20 zhengkai 优化对fulltext/index关键字的处理(感谢@WEGFan的反馈)
308+
// 2025-12-07 zhengkai 修复对primary key的处理
308309
boolean notSpecialFlag = (
309310
!columnLine.contains("key ")
310311
&& !columnLine.contains("constraint")
@@ -316,7 +317,8 @@ public ClassInfo processTableIntoClassInfo(ParamInfo paramInfo) throws Exception
316317
&& !columnLine.contains("buffer_pool")
317318
&& !columnLine.contains("tablespace")
318319
&& !(columnLine.contains("primary ") && columnLine.indexOf("storage") + 3 > columnLine.indexOf("("))
319-
&& !(columnLine.contains("primary ") && i > 3)
320+
&& !(columnLine.toLowerCase().contains("primary ") && i > 3)
321+
&& !columnLine.toLowerCase().contains("primary key")
320322
);
321323

322324
if (notSpecialFlag) {
@@ -416,10 +418,10 @@ public ClassInfo processTableIntoClassInfo(ParamInfo paramInfo) throws Exception
416418
}
417419
}
418420

419-
if (fieldList.size() < 1) {
421+
if (fieldList.isEmpty()) {
420422
throw new Exception("表结构分析失败,请检查语句或者提交issue给我");
421423
}
422-
424+
//build Class Info
423425
ClassInfo codeJavaInfo = new ClassInfo();
424426
codeJavaInfo.setTableName(tableName);
425427
codeJavaInfo.setClassName(className);

0 commit comments

Comments
 (0)