Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

PgSql生成模板字段需要加上双引号 #5

Closed
fanslead opened this issue Oct 19, 2018 · 11 comments
Closed

PgSql生成模板字段需要加上双引号 #5

fanslead opened this issue Oct 19, 2018 · 11 comments
Labels
question Further information is requested

Comments

@fanslead
Copy link

由于PgSql的识别规则,sql语句中表字段需要用双引号包起来,否则执行语句是会异常。
最后生成应该要这样才行。
image

@Ahoo-Wang
Copy link
Member

@fanslead OK,感谢提醒!

:octocat: From gitme Android

@beginor
Copy link
Collaborator

beginor commented Oct 19, 2018

pg 数据库建议使用蛇形 (snake_case) 命名规范, 不要区分大小写

@fanslead
Copy link
Author

pg 数据库建议使用蛇形 (snake_case) 命名规范, 不要区分大小写

昨天已经试过这种命名规范,执行sql依旧出现异常,只有用双引号包起来才能执行

@beginor
Copy link
Collaborator

beginor commented Oct 19, 2018

@fanslead 可能是列中有关键字吧,要不就是 smart sql 的问题了

@Ahoo-Wang
Copy link
Member

@fanslead @beginor SmartSql也只是转发SQL,我猜可能是pg命名的问题。
@fanslead 方便的话给我你的SQL脚本,以便于我今晚复现该问题,并给出修复方案。

@Ahoo-Wang Ahoo-Wang added the question Further information is requested label Oct 19, 2018
@beginor
Copy link
Collaborator

beginor commented Oct 19, 2018

@Ahoo-Wang 数据库有问题? 更多的可能应该是 sql 的问题吧

@Ahoo-Wang
Copy link
Member

@beginor 命名有可能有问题,就是你刚刚说的啊。

:octocat: From gitme Android

@fanslead
Copy link
Author

@Ahoo-Wang 这是sql脚本,我判断应该是pgsql的命名识别规则的原因。
sql.txt

@Ahoo-Wang
Copy link
Member

@fanslead ok,感谢,晚上我来check一下。

@Ahoo-Wang
Copy link
Member

@fanslead @beginor

image
image

image

可以看出SQL语句执行是会全部转成小写的,跟ORM是没有关系的。

下面这条是可以执行成功的,因为都是小写。 建议字段名不要使用大写以免造成不必要的麻烦。
image

@fanslead
Copy link
Author

@Ahoo-Wang OK,我把表字段改成纯小写命名吧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants