Closed engineer-myoa closed 2 years ago
Thank you for your use.
I think use native DDL
sql to generate POJO
and Repo
is a nice feature.
If we want to parse sql, We should use some lightweight sql parser, because we only use the parser/formatter, etc...
:) So, I recommend this repository ddl-parser
I think generating List
This parser is not compatible. Cannot be compatible with schema containing database name. For example:
drop table if exists dbname.table_name;
create table dbname.table_name (
f_id bigint unsigned not null comment 'id',
f_version bigint unsigned not null default 0 comment 'version',
f_created_at bigint unsigned not null comment 'created at',
f_updated_at bigint unsigned not null comment 'updated at',
primary key (f_id)
) engine = InnoDB default charset utf8mb4 comment 'table comment';
And the stack trace:
java.lang.RuntimeException: Illegal character "." at line 0, column 27
at com.moilioncircle.ddl.parser.utils.MySqlToken.nextToken(MySqlToken.java:2024)
at com.moilioncircle.ddl.parser.MysqlDDLParser.nextToken(MysqlDDLParser.java:2313)
at com.moilioncircle.ddl.parser.MysqlDDLParser.match(MysqlDDLParser.java:2324)
at com.moilioncircle.ddl.parser.MysqlDDLParser.name(MysqlDDLParser.java:685)
If we modify the schema, for example:
create table table_name (
f_id bigint unsigned not null comment 'id',
f_version bigint unsigned not null default 0 comment 'version',
f_created_at bigint unsigned not null comment 'created at',
f_updated_at bigint unsigned not null comment 'updated at',
primary key (f_id)
) engine = InnoDB default charset utf8mb4 comment 'table comment';
Output:
TableInfo:
tableName=table_name
pks=[]
columns=[[columnName=f_id, type=BIGINT], [columnName=f_version, type=BIGINT], [columnName=f_created_at, type=BIGINT], [columnName=f_updated_at, type=BIGINT]]
It can't recognized primary key
...
(Sorry, too late response)
You are right. It isn't compatible. Very nice example 👍 That parser also too complex That can not modify.
We can find any other! :)
Now,I have released a new version of the plugin (1.0.7). Support English and 简体中文.
It is too heavy if use only for parser.
But it has advantages also, It is large project. To make dispute or issue easily. And more trusted. (at least other project)
We need to verify this :) (but really sorry, my company is too busy. please forgive me, too late response T.T)
The first, Thank you for your nice project.
When I started some project to development phase, I haven't physical schema. So, I suggest feature for schema read from native ddl sql.
Currently, I'm developing this feature in IPJS-001
But there need some discussion. (e.g Whether to use plug-in for parsing sql, etc ... )
Please review it.