Skip to content

Commit

Permalink
Merge pull request #936 from chat2db/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Chat2DB-Pro committed Dec 7, 2023
2 parents 0af4176 + 15807f6 commit c37dd7f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private static void registryMapperXml(MybatisConfiguration configuration, String
Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
JarEntry jarEntry = entries.nextElement();
if (jarEntry.getName().endsWith(".xml")) {
if (jarEntry.getName().endsWith("Mapper.xml")) {
InputStream in = jarFile.getInputStream(jarEntry);
XMLMapperBuilder xmlMapperBuilder = new XMLMapperBuilder(in, configuration, jarEntry.getName(), configuration.getSqlFragments());
xmlMapperBuilder.parse();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
<artifactId>spring-context</artifactId>
</dependency>

<dependency>
<groupId>com.manticore-projects.jsqlformatter</groupId>
<artifactId>jsqlformatter</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import ai.chat2db.server.tools.base.wrapper.result.DataResult;
import ai.chat2db.server.web.api.aspect.ConnectionInfoAspect;
import ai.chat2db.server.web.api.controller.sql.request.SqlFormatRequest;
import cn.hutool.db.sql.SqlFormatter;
import com.manticore.jsqlformatter.JSQLFormatter;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -19,18 +19,19 @@ public class SqlController {

/**
* SQL Format
*
* @param sqlFormatRequest
* @return
*/
@GetMapping("/format")
public DataResult<String> list(@Valid SqlFormatRequest sqlFormatRequest) {

String sql = sqlFormatRequest.getSql();
try {
sql = SqlFormatter.format(sql);
sql = JSQLFormatter.format(sql);
} catch (Exception e) {
// ignore
}
return DataResult.of(sql);
}

}

0 comments on commit c37dd7f

Please sign in to comment.