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: enhance supports for 'mode' of generations in gentool #1182

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

TremblingV5
Copy link

@TremblingV5 TremblingV5 commented Jul 20, 2024

  • Do only one thing
  • Non breaking API changes
  • Tested

What did this pull request do?

Enhance the ability of gentool by adding a configuration named mode.

I found that gentool not support the argument named mode. In some scenarios, it may be useful. For example, we can use this argument to generate some code with default queries by using gen.WithDefaultQuery.

User Case Description

Command

gentool -mode="WithDefaultQuery,WithoutContext,WithQueryInterface"

gen.yml

version: "0.1"
database:
  # consult[https://gorm.io/docs/connecting_to_the_database.html]"
  dsn : "user:pass@tcp(127.0.0.1:3306)/dbname?charset=utf8mb4&parseTime=True&loc=Local"
  # input mysql or postgres or sqlite or sqlserver. consult[https://gorm.io/docs/connecting_to_the_database.html]
  db  : "mysql"
  # enter the required data table or leave it blank.You can input : 
  # tables  : 
  #   - orders
  #   - users
  #   - goods
  tables  :
  # only generate models (without query file)
  onlyModel : false
  # specify a directory for output
  outPath :  "./dao/query"
  # query code file name, default: gen.go
  outFile :  ""
  # generate unit test for query code
  withUnitTest  : false
  # generated model code's package name
  modelPkgName  : ""
  # generate with pointer when field is nullable
  fieldNullable : false
  # generate with pointer when field has default value
  fieldCoverable : false
  # generate field with gorm index tag
  fieldWithIndexTag : false
  # generate field with gorm column type tag
  fieldWithTypeTag  : false
  # detect integer field's unsigned type, adjust generated data type
  fieldSignable  : false
  # generate mode
  mode  :
    - WithDefaultQuery
    - WithoutContext
    - WithQueryInterface

@TremblingV5 TremblingV5 changed the title support for 'mode' in gentool enhance supports for 'mode' of generations in gentool Jul 20, 2024
@TremblingV5 TremblingV5 changed the title enhance supports for 'mode' of generations in gentool feat: enhance supports for 'mode' of generations in gentool Jul 20, 2024
@TremblingV5 TremblingV5 reopened this Jul 20, 2024
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.

1 participant