查看SQL兼容性并查看不兼容SQL语句对应的功能点报错
由于实践所用的RuoYi应用涉及到100+条SQL语句,语句数量较多,本实践仅选取3类不兼容的问题(共涉及4条SQL语句)进行改造实践。
源文件 |
来源 |
SQL ID |
DevKit工具提取出的不兼容的SQL语句 |
不兼容类型 |
---|---|---|---|---|
ruoyi-system/src/main/resources/mapper/system/SysUserOnlineMapper.xml |
mapper xml |
saveOnline |
replace into sys_user_online(sessionId, login_name, dept_name, ipaddr, login_location, browser, os, status, start_timestamp, last_access_time, expire_time) values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) |
DM8不支持replace into的用法 |
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java |
注解 |
\ |
select notice_id, notice_title, notice_type, cast(notice_content as char) as notice_content, status, create_by, create_time, update_by, update_time, remark from sys_notice where notice_id = 1 |
DM8中的cast函数不支持将blob类型转换成字符串类 |
注解 |
\ |
select notice_id, notice_title, notice_type, cast(notice_content as char) as notice_content, status, create_by, create_time, update_by, update_time, remark from sys_notice WHERE notice_title like concat('%', 1, '%') AND notice_type = 1 AND create_by like concat('%', 1, '%') |
DM8中的cast函数不支持将blob类型转换成字符串类 |
|
ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml |
mapper xml |
selectDbTableList |
select table_name, table_comment, create_time, update_time from information_schema.tables where table_schema = (select database()) AND table_name NOT LIKE 'QRTZ_%' AND table_name NOT LIKE 'gen_%' AND table_name NOT IN (select table_name from gen_table) AND lower(table_name) like lower(concat('%', 1, '%')) AND lower(table_comment) like lower(concat('%', 1, '%')) order by create_time desc |
DM8没有information_schema等MySQL自带的数据库表 |
上述表格中“DevKit工具提取出的不兼容的SQL语句”来源DevKit工具迁移结果页面的“查看详情”,如下图:
。以上述表格中最后一条SQL为例,单击查看详情中,找到“id”为“selectDbTableList”的语句,鼠标悬浮到黄色波浪线上,即可查看工具提取拼接后的SQL语句。单击“复制SQL代码段”可以将提取出的SQL语句快速复制下来。
查看SQL兼容性问题
- 打开桌面上的DM管理工具,新建连接,填写数据库连接信息,测试连接。如下图所示:
- 新建查询,并修改当前查询窗口的模式为“ry”。
- 将上方表格中的SQL语句复制粘贴至查询窗口中,点击绿色箭头执行语句,查看报错。