Skip to content
This repository has been archived by the owner on May 25, 2022. It is now read-only.

Commit

Permalink
fix(db): fix insert statement issue
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Apr 13, 2022
1 parent 32394cd commit 067bef9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Expand Up @@ -15,10 +15,9 @@ object MysqlIdentApp {

try {
val statement: Statement = CCJSqlParserUtil.parse(sql)
val selectStatement: Select = statement as Select
val tablesNamesFinder = TablesNamesFinder()

table.tableNames = tablesNamesFinder.getTableList(selectStatement).map {
table.tableNames = tablesNamesFinder.getTableList(statement).map {
var tableName = it
if (it.startsWith("`") && it.endsWith("`")) {
tableName = tableName.removeSuffix("`").removePrefix("`")
Expand Down
Expand Up @@ -51,4 +51,12 @@ internal class MysqlIdentAppTest {

assertEquals("system_info", relation!!.tableNames.joinToString(","))
}
}

@Test
internal fun should_parse_for_mybatis_questions() {
val code = "INSERT INTO oms_order_operate_history (order_id, operate_man, create_time, order_status, note) VALUES (?, ?, ?, ?, ?)"
val relation = MysqlIdentApp.analysis(code)

assertEquals("oms_order_operate_history", relation!!.tableNames.joinToString(","))
}
}

0 comments on commit 067bef9

Please sign in to comment.