Skip to content

[Queries] [MySQL] Generated queries ignore type replacements for base table columns #523

@jacobmolby

Description

@jacobmolby

Given a bobgen.yaml with following replacements:

replacements:
  - match:
      name: "id"
    replace: uint64
  - match:
      name: "team_id"
    replace: uint64

And a generated models.shops like the following:

type Shop struct {
	ID                 uint64                                `db:"id,pk,autoincr" json:"id"`
	TeamID             uint64                                `db:"team_id" json:"team_id"`
         //...
}

And a SQL query that looks like this:

-- Shops
SELECT
    `shops`.`id`,
    `shops`.`team_id`
FROM
    `shops`;

It will generate the result struct without looking at the replacements:

type ShopsRow = struct {
	ID     int32 `db:"id"`
	TeamID int32 `db:"team_id"`
}

Of course you could annotate it, but I think it would be more natural if it defaults to using the replacements, which then could be overwritten with annotations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions