当前使用版本(必须填写清楚,否则不予处理)

mybatis-plus-generator: 3.3.1.tmp

该问题是怎么引起的?(最新版上已修复的会直接close掉)

使用MyBatisPlus代码生成器连接SQL Server2014中SQL语句语法错误,导致代码生成失败. 在连接过程中,mybatis-plus-generator会生成如下语句:

select cast(so.name as varchar(500)) as TABLE_NAME, cast(sep.value as varchar(500)) as COMMENTS from sysobjects so left join sys.extended_properties sep on sep.major_id=so.id and sep.minor_id =0 where (xtype='U' or xtype='v') AND TABLE_NAME in ('table1', 'table2')

但这个语句中: TABLE_NAME 是别名无法在 where 语句中使用的。 正确写法应该是:

select cast(so.name as varchar(500)) as TABLE_NAME, cast(sep.value as varchar(500)) as COMMENTS from sysobjects so left join sys.extended_properties sep on sep.major_id=so.id and sep.minor_id =0 where (xtype='U' or xtype='v') AND so.name in ('table1', 'table2')

重现步骤

使用mybatis-plus-generator: 3.3.1.tmp 连接SQL Server 2014,生成代码

报错信息

com.microsoft.sqlserver.jdbc.SQLServerException: Invalid column name 'TABLE_NAME'

Comment From: nieqiurong

1917