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

feat: add custom field type mapping support for command gf gen dao #3498

Merged
merged 18 commits into from
Apr 25, 2024

Conversation

CyJaySong
Copy link
Contributor

gf gen dao support type mapping for specific field of table

@CyJaySong
Copy link
Contributor Author

@gqcn 麻烦review一下

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@gqcn Please review it

@gqcn gqcn changed the title gf gen dao support type mapping for specific field of table feat: add custom field type mapping support for command gf gen dao Apr 22, 2024
@gqcn
Copy link
Member

gqcn commented Apr 22, 2024

Interesting feature!
@hailaz @houseme @DGuang21 @oldme-git @wln32 Hi guys, would you please take a look together?

@hailaz
Copy link
Member

hailaz commented Apr 22, 2024

支持,我之前有想过,之前单纯指定类型并不够灵活,应该表名加字段加类型这样更好。现在有人实现了(¯▽¯)👍

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Yes, I have thought before that simply specifying the type is not flexible enough. It would be better to add the table name, field and type. Now someone has achieved it(¯▽¯)👍

@hailaz
Copy link
Member

hailaz commented Apr 23, 2024

你们说有没有可能和原来的TypeMapping结合到一起,不过这样的使用难度会提高不少。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Do you think it is possible to combine it with the original TypeMapping, but it will be much more difficult to use.

@CyJaySong
Copy link
Contributor Author

你们说有没有可能和原来的TypeMapping结合到一起,不过这样的使用难度会提高不少。

@hailaz TypeMapping 适用于按照数据库字段类型批量映射,FieldMapping适用于表字段特定指定类型。比如,json 类型,我们为了开发方便会建一个结构体进行映射

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Do you think it is possible to combine it with the original TypeMapping, but it will be much more difficult to use.

@hailaz TypeMapping is suitable for batch mapping according to database field types, and FieldMapping is suitable for specific specified types of table fields. For example, for the json type, we will build a structure for mapping for the convenience of development.

@houseme
Copy link
Member

houseme commented Apr 24, 2024

TypeMapping 碰到必须优先引入这个依赖才可以生成dao成功,如果在表创建时在引入会出现失败的情况,建议不上这一块的test

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


TypeMapping must first introduce this dependency before the DAO can be generated successfully. If the introduction fails when the table is created, it is not recommended to test this part.

@CyJaySong
Copy link
Contributor Author

CyJaySong commented Apr 24, 2024

TypeMapping 碰到必须优先引入这个依赖才可以生成dao成功,如果在表创建时在引入会出现失败的情况,建议不上这一块的test

cli中执行shell 的问题,PR中修复了的

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


TypeMapping must first introduce this dependency before the dao can be generated successfully. If the introduction fails when the table is created, it is not recommended to test this part.

The problem of executing shell in cli is fixed in PR

cmd/gf/internal/cmd/gendao/gendao.go Outdated Show resolved Hide resolved
@CyJaySong CyJaySong requested a review from gqcn April 24, 2024 15:03
@gqcn gqcn merged commit 5b7cae7 into gogf:master Apr 25, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants