Skip to content

Query and column overrides use different types for the same underlying database type #3063

Open
@kyleconroy

Description

@kyleconroy
  - db_type: "pg_catalog.numeric"
    nullable: false                          
    go_type:
      import: "yapi/types"
      type: "Decimal"
  - db_type: "pg_catalog.numeric"
    nullable: true                          
    go_type:
      import: "yapi/types"
      type: "Decimal"        

this was generating model ok, but not the queries. I fixed it by duplicating the above for numeric type but without the schema

  - db_type: "numeric"
    nullable: false                          
    go_type:
      import: "yapi/types"
      type: "Decimal"
  - db_type: "numeric"
    nullable: true                          
    go_type:
      import: "yapi/types"
      type: "Decimal"   

The issue appears in gen.go file here

structs := buildStructs(req, options)
queries, err := buildQueries(req, options, structs)

buildStructs works off schema.Tables, while buildQueries off req.Queries.Params

These functions need to be aligned to use schema data from the same source.

I'll just stick with my workaround for now, as I don't have time to fix this - it appears some significant changes may be required here.

This misalignment is likely to cause other issues, I'm sure.

Originally posted by @shkvoretz in #3005 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions