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

gf gen dao link option doesn't work #3459

Closed
smokecat opened this issue Apr 8, 2024 · 2 comments · Fixed by #3531
Closed

gf gen dao link option doesn't work #3459

smokecat opened this issue Apr 8, 2024 · 2 comments · Fixed by #3531
Assignees
Labels
bug It is confirmed a bug, but don't worry, we'll handle it. CLI about gf cli

Comments

@smokecat
Copy link

smokecat commented Apr 8, 2024

What version of Go and system type/arch are you using?
go version go1.22.1 darwin/arm64

What version of GoFrame are you using?
v2.6.4

Can this bug be re-produced with the latest release?
Yes

What did you do?

local postgreSQL database configuration:

host: 127.0.0.1
port: 5432
user: postgres
password: abcd1234
database: my_app

file hack/config.yaml:

gfcli:
  gen:
    dao:
      - link: "pgsql:postgres:postgres@tcp(127.0.0.1:5432)/postgres"

I executed the cmd:

gf gen dao -l "pgsql:postgres:abcd1234@tcp(127.0.0.1:5432)/my_app"

What did you expect to see?
Generate dao successfully.

What did you see instead?

fetching tables failed: SELECT c.relname FROM pg_class c INNER JOIN pg_namespace n ON c.relnamespace = n.oid WHERE n.nspname = 'public' AND c.relkind IN ('r', 'p') ORDER BY c.relname: pq: password authentication failed for user "postgres"
1. SELECT c.relname FROM pg_class c INNER JOIN pg_namespace n ON c.relnamespace = n.oid WHERE n.nspname = 'public' AND c.relkind IN ('r', 'p') ORDER BY c.relname
   1).  reflect.Value.call
        /opt/homebrew/Cellar/go/1.22.1/libexec/src/reflect/value.go:596
   2).  reflect.Value.Call
        /opt/homebrew/Cellar/go/1.22.1/libexec/src/reflect/value.go:380
   3).  runtime.main
        /opt/homebrew/Cellar/go/1.22.1/libexec/src/runtime/proc.go:271
   4).  runtime.goexit
        /opt/homebrew/Cellar/go/1.22.1/libexec/src/runtime/asm_arm64.s:1222
2. pq: password authentication failed for user "postgres"
@smokecat smokecat added the bug It is confirmed a bug, but don't worry, we'll handle it. label Apr 8, 2024
@hailaz
Copy link
Member

hailaz commented Apr 8, 2024

err: pq: password authentication failed for user "postgres"
check your password and use --gf.debug=true

gf gen dao -l "pgsql:postgres:12345678@tcp(127.0.0.1:5432)/postgres"  --gf.debug=true
generated: internal\dao\user.go
generated: internal\dao\internal\user.go
generated: internal\model\do\user.go    
generated: internal\model\entity\user.go
done!

@smokecat
Copy link
Author

smokecat commented Apr 9, 2024

err: pq: password authentication failed for user "postgres"
check your password and use --gf.debug=true

gf gen dao -l "pgsql:postgres:12345678@tcp(127.0.0.1:5432)/postgres"  --gf.debug=true
generated: internal\dao\user.go
generated: internal\dao\internal\user.go
generated: internal\model\do\user.go    
generated: internal\model\entity\user.go
done!

It can be confirmed that the real user, password and database of the database should be the value specified by the '-l' parameter, but the value in 'config.yaml' is used to run the command, so the validation fails.

$ gf gen dao -l "pgsql:postgres:abcd1234@tcp(127.0.0.1:5432)/my_app" --gf.debug=true
2024-04-09 12:28:49.262 [INTE] gbuild.go:55 no build variables
2024-04-09 12:28:49.267 [INTE] gres_resource.go:57 Add 184 files to resource manager
2024-04-09 12:28:49.268 [INTE] gres_resource.go:57 Add 263 files to resource manager
2024-04-09 12:28:49.276 [INTE] gcfg_adapter_file_path.go:168 AddPath:/Users/smoke/workspace/repo/_xteam/X-Server
2024-04-09 12:28:49.278 [INTE] gcfg_adapter_file_path.go:168 AddPath:/Users/smoke/go/pkg/mod/github.com/gogf/gf/cmd/gf/v2@v2.6.4
2024-04-09 12:28:49.279 [INTE] gcfg_adapter_file_path.go:168 AddPath:/Users/smoke/go/bin
2024-04-09 12:28:49.279 [INTE] gcfg_adapter_file_path.go:91 SetPath:/Users/smoke/workspace/repo/_xteam/X-Server/hack
2024-04-09 12:28:49.283 [INTE] gfsnotify_watcher.go:100 watcher adds monitor for: /Users/smoke/workspace/repo/_xteam/X-Server/hack/config.yaml
2024-04-09 12:28:49.283 [INTE] gcmd_command_object.go:300 {80fb76963682c417d1cc5a0fc49147af} input command data map: {"DaoPath":"dao","DoPath":"model/do","EntityPath":"model/entity","Group":"default","JsonCase":"CamelLower","Path":"internal","l":"pgsql:postgres:abcd1234@tcp(127.0.0.1:5432)/my_app","link":"pgsql:postgres:abcd1234@tcp(127.0.0.1:5432)/my_app"}
2024-04-09 12:28:49.284 [INTE] gcmd_command_object.go:308 {80fb76963682c417d1cc5a0fc49147af} input object assigned data: {"Path":"internal","Link":"pgsql:postgres:abcd1234@tcp(127.0.0.1:5432)/my_app","Tables":"","TablesEx":"","Group":"default","Prefix":"","RemovePrefix":"","RemoveFieldPrefix":"","JsonCase":"CamelLower","ImportPrefix":"","DaoPath":"dao","DoPath":"model/do","EntityPath":"model/entity","TplDaoIndexPath":"","TplDaoInternalPath":"","TplDaoDoPath":"","TplDaoEntityPath":"","StdTime":false,"WithTime":false,"GJsonSupport":false,"OverwriteDao":false,"DescriptionTag":false,"NoJsonTag":false,"NoModelComment":false,"Clear":false,"TypeMapping":null}
2024-04-09 12:28:49.284 [INTE] gi18n_manager.go:103 New: &gi18n.Manager{mu:sync.RWMutex{w:sync.Mutex{state:0, sema:0x0}, writerSem:0x0, readerSem:0x0, readerCount:atomic.Int32{_:atomic.noCopy{}, v:0}, readerWait:atomic.Int32{_:atomic.noCopy{}, v:0}}, data:map[string]map[string]string(nil), pattern:"\\{#(.+?)\\}", pathType:"normal", options:gi18n.Options{Path:"/Users/smoke/workspace/repo/_xteam/X-Server/manifest/i18n", Language:"en", Delimiters:[]string{"{#", "}"}, Resource:(*gres.Resource)(0x14000198118)}}
2024-04-09 12:28:49.284 [INTE] gdb_driver_wrapper_db.go:31 open new connection:{"host":"127.0.0.1","port":"5432","user":"postgres","pass":"postgres","name":"postgres","type":"pgsql","link":"","extra":"","role":"","debug":false,"prefix":"","dryRun":false,"weight":0,"charset":"utf8","protocol":"tcp","timezone":"","namespace":"","maxIdle":0,"maxOpen":0,"maxLifeTime":0,"queryTimeout":0,"execTimeout":0,"tranTimeout":0,"prepareTimeout":0,"createdAt":"","updatedAt":"","deletedAt":"","timeMaintainDisabled":false}
2024-04-09 12:28:49.325 [FATA] /opt/homebrew/Cellar/go/1.22.1/libexec/src/runtime/proc.go:271: fetching tables failed: SELECT c.relname FROM pg_class c INNER JOIN pg_namespace n ON c.relnamespace = n.oid WHERE n.nspname = 'public' AND c.relkind IN ('r', 'p') ORDER BY c.relname: pq: password authentication failed for user "postgres"
1. SELECT c.relname FROM pg_class c INNER JOIN pg_namespace n ON c.relnamespace = n.oid WHERE n.nspname = 'public' AND c.relkind IN ('r', 'p') ORDER BY c.relname
   1).  reflect.Value.call
        /opt/homebrew/Cellar/go/1.22.1/libexec/src/reflect/value.go:596
   2).  reflect.Value.Call
        /opt/homebrew/Cellar/go/1.22.1/libexec/src/reflect/value.go:380
   3).  runtime.main
        /opt/homebrew/Cellar/go/1.22.1/libexec/src/runtime/proc.go:271
   4).  runtime.goexit
        /opt/homebrew/Cellar/go/1.22.1/libexec/src/runtime/asm_arm64.s:1222
2. pq: password authentication failed for user "postgres"
 
Stack:
1.  runtime.main
    /opt/homebrew/Cellar/go/1.22.1/libexec/src/runtime/proc.go:271
2.  runtime.goexit
    /opt/homebrew/Cellar/go/1.22.1/libexec/src/runtime/asm_arm64.s:1222

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It is confirmed a bug, but don't worry, we'll handle it. CLI about gf cli
Projects
None yet
4 participants