gf-cli icon indicating copy to clipboard operation
gf-cli copied to clipboard

postgresq的 schema 问题

Open sootma opened this issue 3 years ago • 2 comments

在postgresql gf gen dao时,总是使用sql: SELECT TABLENAME FROM PG_TABLES WHERE SCHEMANAME = 'public' ORDER BY TABLENAME 倒致取不到数据,因为我没有用到public,而是用的其实scheme, 没有找到可以配置这个schema的地方

sootma avatar Jul 05 '21 08:07 sootma

@sootma 这个地方是在gf框架那边硬编码的,你可以贡献PR

gqcn avatar Jul 06 '21 11:07 gqcn

我现在是直接临时修改了源码command/gen/gen_dao.go line 233: tableNames, err = db.Tables(context.TODO()) => tableNames, err = db.Tables(context.TODO(), "xxx") xxx为自己的schema。这样可以生成自己需要的schema.

另外,我建议:dao生成的表名,加上schema, 这样就可以不需要user与schema一致了。现在临时的做法是,连接的用户名与schema一致。

sootma avatar Jul 08 '21 01:07 sootma