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

数据表内两个字段名称相似不规范时会导致查询异常 #1700

Closed
AShujiao opened this issue Mar 24, 2022 · 1 comment
Closed
Labels
done This issue is done, which may be release in next version. enhancement

Comments

@AShujiao
Copy link

AShujiao commented Mar 24, 2022

gf版本:1.16

例:shop表
字段:id、userid、user_id

1、使用gf-cli生成模型--正常
2、查询数据
image

R}RZ5JQ%V}B`S1)J 51GVKN

查看控制台时发现生成的sql为如图所示。

3、尝试指定字段
image
image

经过多次debug发现userid、user_id只会有一个字段有值,无法同时两个字段都有值,要么userid有,要么user_id有。

4、目前解决方法
修改生成的model增加uid字段,查询时使用user_id as uid。
由于业务需要不能改数据表字段,只能改model兼容处理

(涉及敏感信息不方便全部截图,英文太渣可能描述不清楚还是用中文好了)

@houseme
Copy link
Member

houseme commented Mar 24, 2022

userid、user_id、userId、userID都认为是一个字段。

gqcn added a commit that referenced this issue Apr 8, 2022
gqcn added a commit that referenced this issue Apr 11, 2022
@gqcn gqcn added enhancement done This issue is done, which may be release in next version. labels Apr 11, 2022
@gqcn gqcn closed this as completed Apr 11, 2022
houseme pushed a commit to houseme/gf that referenced this issue Apr 18, 2022
houseme pushed a commit to houseme/gf that referenced this issue Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
done This issue is done, which may be release in next version. enhancement
Projects
None yet
Development

No branches or pull requests

3 participants