Crates.io | xbatis2sql |
lib.rs | xbatis2sql |
version | 0.2.5 |
source | src |
created_at | 2022-11-21 03:52:22.93002 |
updated_at | 2023-08-14 16:29:09.320412 |
description | collect sql statements from iBATIS sqlmap files/MyBatis mapper files |
homepage | https://github.com/hellyguo/xbatis2sql |
repository | https://github.com/hellyguo/xbatis2sql |
max_upload_size | |
id | 719688 |
size | 80,113 |
xbatis2sql
, collect sql statements from iBATIS sqlmap files/MyBatis mapper files.
cargo install xbatis2sql
# xbatis2sql -h
Usage: xbatis2sql [-i|-m] -t [Oracle/MySQL] -s ... -o ...
Options:
-i, --ibatis try to parse iBATIS sqlmap files
-m, --mybatis try to parse MyBatis mapper files
-t, --type DB db type
-s, --src SRC source directory
-o, --output OUTPUT output directory
-h, --help print this help menu
xbatis2sql -i -t Oracle -s /java/use_ibatis_proj/src -o /tmp
or
xbatis2sql --ibatis --type Oracle --src /java/use_ibatis_proj/src --output /tmp
After executing, the result will be exist in /tmp/result.sql
.
xbatis2sql -m -t Oracle -s /java/use_mybatis_proj/src -o /tmp
or
xbatis2sql --mybatis --type Oracle --src /java/use_mybatis_proj/src --output /tmp
After executing, the result will be exist in /tmp/result.sql
.
mapper-demo.xml will be converted to result.sql
.
result.sql
SELECT "XML -FILE: ./test_data/mapper-demo.xml" AS XML_FILE FROM DUAL;
SELECT "STAT -ID: insert" AS STAT_ID FROM DUAL;
INSERT INTO TAB1(A,B,C,D) VALUES (:?,:?,:?,:?);
SELECT "STAT -ID: insert.selectKey" AS STAT_ID FROM DUAL;
SELECT 1 FROM DUAL;
SELECT "STAT -ID: select" AS STAT_ID FROM DUAL;
SELECT * FROM TAB1 WHERE COLUMN1 IN ( :?);
SELECT "STAT -ID: insert2" AS STAT_ID FROM DUAL;
INSERT INTO TAB2 ( ID)VALUES ( :?);
SELECT "STAT -ID: select2" AS STAT_ID FROM DUAL;
SELECT COLUMN1, COLUMN2 , (SELECT 1 FROM DUAL) FROM TAB3 WHERE COLUMN1 = :? ORDER BY COLUMN2 DESC;
SELECT "STAT -ID: update" AS STAT_ID FROM DUAL;
UPDATE TAB1 SET COLUMN1 = :? WHERE COLUMN1 = :?;
SELECT "STAT -ID: delete" AS STAT_ID FROM DUAL;
DELETE FROM TAB1 WHERE COLUMN1 = :? AND COLUMN2 = :?;
sqlmap-demo.xml will be converted to result.sql
.
result.sql
SELECT "XML -FILE: ./test_data/sqlmap-demo.xml" AS XML_FILE FROM DUAL;
SELECT "STAT -ID: select" AS STAT_ID FROM DUAL;
SELECT COUNT(1) , (SELECT 1 FROM DUAL) FROM __REPLACE_SCHEMA__.TAB1 WHERE COLUMN1 = 'BALABALA' AND COLUMN2 = :?;
SELECT "STAT -ID: update" AS STAT_ID FROM DUAL;
UPDATE __REPLACE_SCHEMA__.TAB2 SET COLUMN2 = :? WHERE COLUMN1 = :?;
SELECT "STAT -ID: delete" AS STAT_ID FROM DUAL;
DELETE FROM __REPLACE_SCHEMA__.TAB1 WHERE COLUMN1 = :?;
SELECT "STAT -ID: insert" AS STAT_ID FROM DUAL;
INSERT INTO __REPLACE_SCHEMA__.TAB1 (COLUMN1, COLUMN2, COLUMN3, COLUMN4, COLUMN5) VALUES (:?, :?, :?, :?, :?);
If under
MySQL
mode,:?
will be replaced with@1
.
See in ChangeLog
Thanks to mybatis-mapper-2-sql / sqle