Skip to content

sqlboiler generates int instead of int32 for PostgreSQL int4 type, causing type inconsistency #1464

@Lirous587

Description

@Lirous587

Problem Description

When using sqlboiler with PostgreSQL, int4 (integer) columns are generated as int type in Go structs instead of int32. This causes type inconsistency issues because:

  1. PostgreSQL int4 is always 32-bit regardless of platform
  2. Go int is platform-dependent (32-bit on 32-bit systems, 64-bit on 64-bit systems)
  3. This leads to unnecessary type conversions and potential overflow issues on 32-bit systems

Current Behavior

PostgreSQL Schema:

CREATE TABLE img_category (
    id SERIAL PRIMARY KEY,  -- int4 type
    ......
);

Generated Go Code:

type ImgCategory struct {
    ID    int    `boil:"id" json:"id" toml:"id" yaml:"id"`
    ......
}

Expected Behavior

type ImgCategory struct {
    ID    int32  `boil:"id" json:"id" toml:"id" yaml:"id"`
   ......
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions