Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The sum of lengths becomes a float instead of an int. #3331

Open
mondy opened this issue Apr 13, 2024 · 1 comment
Open

The sum of lengths becomes a float instead of an int. #3331

mondy opened this issue Apr 13, 2024 · 1 comment
Labels
bug Something isn't working triage New issues that hasn't been reviewed

Comments

@mondy
Copy link

mondy commented Apr 13, 2024

Version

1.26.0

What happened?

Input:

-- name: GetSize :one
SELECT sum(length(data)) FROM authors;

Output:

func (q *Queries) GetSize(ctx context.Context) (sql.NullFloat64, error) {
	row := q.db.QueryRowContext(ctx, getSize)
	var sum sql.NullFloat64
	err := row.Scan(&sum)
	return sum, err
}

Shouldn't the output NullFloat64 become NullInt64?

Relevant log output

No response

Database schema

CREATE TABLE authors (
  data BLOB NOT NULL
);

SQL queries

-- name: GetSize :one
SELECT sum(length(data)) FROM authors;

Configuration

{
  "version": "2",
  "sql": [{
    "schema": "schema.sql",
    "queries": "query.sql",
    "engine": "sqlite",
    "gen": {
      "go": {
        "out": "db"
      }
    }
  }]
}

Playground URL

https://play.sqlc.dev/p/66dd776b0c5aac077388f94ebc16d73088d78b36d0b8218113683aa13a371687

What operating system are you using?

Windows

What database engines are you using?

SQLite

What type of code are you generating?

Go

@mondy mondy added bug Something isn't working triage New issues that hasn't been reviewed labels Apr 13, 2024
@mondy
Copy link
Author

mondy commented Apr 14, 2024

Related to #3122.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage New issues that hasn't been reviewed
Projects
None yet
Development

No branches or pull requests

1 participant