Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

mapper文件中select语句字段别名用单引号导致不兼容postgresql,抛异常 #426

Closed
liaoyongxiong opened this issue Aug 16, 2019 · 2 comments

Comments

@liaoyongxiong
Copy link

版本号:2.0.2
问题描述:

关于单引、双引号。
MySQL 可以使用单引号(’)或者双引号(")表示值,但是 PG 只能用单引号(’)表示值,PG 的双引号(")是表示系统标识符的,比如表名或者字段名。MySQL可以使用反单引号(`)表示系统标识符,比如表名、字段名,PG 也是不支持的。
jeecg-boot平台代码中,mapper文件中有一些 select语句在给输出字段起别名时,用单引号导致了对PostgreSql不兼容(查询抛出异常了)
建议mapper文件中,字段用双引号(单引号修改为双引号),需要修改的文件如下

截图&代码:

兼容Postgresql,需要修改的表:
1、org/jeecg/modules/ngalain/mapper/xml/NgAlainMapper.xml
修改前select ${key} as ‘label’,${value} as ‘value from ${table}
修改后 select ${key} as "label",${value} as "value" from ${table}

2、org/jeecg/modules/system/mapper/xml/SysCategoryMapper.xml
修改前:
select code,
name as "title",
id as 'key',
(case has_child when '1' then 0 else 1 end) as isLeaf,
pid as parentId
from sys_category
where pid = #{pid}
修改后
select code,
name as "title",
id as “key”,
(case has_child when '1' then 0 else 1 end) as isLeaf,
pid as parentId
from sys_category
where pid = #{pid}

3、org/jeecg/modules/system/mapper/xml/SysDictMapper.xml
select查询语句中, 字段别名的单引号改为双引号,有多处修改,逐一修改

@fly1206
Copy link

fly1206 commented Aug 16, 2019

非常感谢 已收录

@zhangdaiscott
Copy link
Member

已经处理,下个版本发布

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants