Skip to content

fix: fix path of the file output from the tool #1092

Closed
k-takeuchi220 wants to merge 1 commit intogo-gorm:masterfrom
k-takeuchi220:fix/output_path
Closed

fix: fix path of the file output from the tool #1092
k-takeuchi220 wants to merge 1 commit intogo-gorm:masterfrom
k-takeuchi220:fix/output_path

Conversation

@k-takeuchi220
Copy link
Copy Markdown

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

What did this pull request do?

Due to the following problems, we have changed the output destination of the files.

Problem 1

When specified as follows, the model file is created in ./src/model:
What I expect is for the model file to be created in ./src/domain/model:

gentool -dsn "" -onlyModel -outPath "src/domain"

Problem 2

Using the modelPkgName option also exhibits strange behavior when specifying a string containing a path separator.
In this case, since outPath is not specified, it is expected that the model files would be generated in dto/model/src/domain, but in reality, they are created in ./src/domain.

gentool -dsn "" -onlyModel -modelPkgName "src/domain"
Current behavior

If modelPkgName does not contain a path separator, output the model files to outPath + modelPkgName.
If modelPkgName contains a path separator, output the model files to the path specified in modelPkgName.

Problem 3

The outputPath specifies the location of the query folder, and the location of the model file is determined accordingly.
However, from a naming perspective, I think this is confusing and not a suitable behavior.

User Case Description

Behavior after modification

I have added an option called queryPkgName. The destination for generating query files will be outPath + queryPkgName. This applies similarly if queryPkgName contains a path separator.

Likewise, the destination for generating model files will be outPath + modelPkgName. This also applies similarly if modelPkgName contains a path separator.

There is no change in default behavior if no output destination is specified. However, it is important to note that if the outPath option and modelPkgName option are specified and used, the generated results may differ.

@qqxhb
Copy link
Copy Markdown
Member

qqxhb commented Mar 2, 2026

Thanks for the PR and the detailed write-up — the motivation makes sense.

However, the current approach changes the semantics of existing options in a way that would be breaking for existing users:

  • Today many users treat OutPath as the query output directory (default ./dao/query). With this PR, the same config would start generating query files under OutPath + QueryPkgPath (e.g. ./dao/query/query/...), which is a significant behavior change.
  • getModelOutputPath() is also changed to always be Join(OutPath, ModelPkgPath), which differs from the current behavior when modelPkgName contains path separators.

Given the scope (public gen.Config changes + generator behavior + docs/tests) and the lack of CI checks on the branch, we’re not comfortable merging this as-is.

Workarounds without upstream changes:

  • If you want models under src/domain/model, you can pass a path in -modelPkgName, e.g. -modelPkgName "src/domain/model".

If you’d like to revisit this, I think the safest direction would be keeping gen.Config behavior stable and implementing the path mapping in gentool only (e.g. separate modelOutPath/queryOutPath flags, or special handling for onlyModel).

Happy to take another look if you can rebase onto latest master and propose a non-breaking, gentool-scoped change.

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.

2 participants