stephenafamo/bob

Postgres generated code does not compile

plunkettscott opened this issue · 1 comments

I updated to v0.22.0 and the generated code for my Postgres database will not compile due to type errors in various methods. Apologies in advance for screenshots of code, but it highlights the problem areas easier than trying to explain myself.

CleanShot 2023-08-21 at 21 26 26

All of these have the same underlying error:

too many return values
	have (int64, error)
	want (error)

In addition to these methods, the query starter methods appear to also result in type errors:

CleanShot 2023-08-21 at 21 28 38

cannot use OrgExpressionVersions.Query(ctx, exec, append(mods, sm.Where(OrgExpressionVersionColumns.ExpressionID.EQ(psql.Arg(o.ID))))...) (value of type *psql.TableQuery[*OrgExpressionVersion, OrgExpressionVersionSlice, *OrgExpressionVersionSetter]) as *psql.ViewQuery[*OrgExpressionVersion, OrgExpressionVersionSlice] value in return statement

Let me know if a reproduction would be easier. Here is my bobgen.yaml file in case its something specific to my configuration:

xidReplacement: &xidReplacement
  replace:
    type: xid.ID
    imports: ['"github.com/rs/xid"']
psql:
  except:
    public.migrations: []
    public.schema_migrations: []
  output: "internal/database/models"
  pkgname: "models"
  schemas:
    - public
replacements:
  - <<: *xidReplacement
    match:
      domain_name: xid
  - <<: *xidReplacement
    match:
      domain_name: xid
      nullable: true

This was my bad. The go get -u I did after generating was ran in a different project. 🤦🏻