Skip to content

Generated code for float column in MySQL is of type interface{} instead of float64 #2095

@Hirochon

Description

@Hirochon

What do you want to change?

Hello,

I am a new contributor to sqlc and I am trying to generate type-safe Go code from SQL queries in MySQL. However, I have noticed that when I specify a float column in MySQL, the generated code is of type interface{} instead of float64, which is a Go type.

For example, when using the following SQL:

-- +migrate Up
create table `extract_complete` (
    `id` char(26) not null unique comment,
    `progress` float not null comment,
    primary key (`id`)
) engine=InnoDB default charset=utf8mb4;

-- +migrate Down
DROP TABLE IF EXISTS `extract_complete`;

The generated Go code looks like this:

type ExtractComplete struct {
	ID string `json:"id"`
	Progress interface{} `json:"progress"`
}

I believe that in order to maintain type safety and compatibility with Go code, the generated code should reflect the data types specified in the SQL queries. Therefore, I would like to contribute to sqlc by implementing support for float64 columns in MySQL.

If it is alright with the maintainers, I would like to submit a Pull Request to add this functionality.

Can someone please guide me on how to go about this? Any help would be greatly appreciated.

Thank you and looking forward to contributing to sqlc!

What database engines need to be changed?

MySQL

What programming language backends need to be changed?

Go

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesttriageNew issues that hasn't been reviewed

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions