Skip to content

Subquery with count as alias compiles to interface{} type [MySQL Only] #1383

@HenkVanMaanen

Description

@HenkVanMaanen

Version

1.11.0

What happened?

When compiling the subquery alias compiles to the interface{} type instead of int64. See playground: https://play.sqlc.dev/p/1f6e668fb3015032c9e28259e03ef5a8d0a045a543d6b367f23642c424116a44

Here is the example with postgres working just fine: https://play.sqlc.dev/p/460a9eedb3b1fa2649415cb09eeb9e7a30b8c35512ea47312e1fd8f12d58f2d5

Relevant log output

No response

Database schema

create table one (
  id int primary key,
  otherfield varchar(255),
  name varchar(255)
);

SQL queries

-- name: Test :many
select 
	otherfield, 
	(select COUNT(*) from one o where one.id = 5 limit 1) as cnt
from one;

Configuration

{
  "version": "1",
  "packages": [
    {
      "path": "db",
      "engine": "mysql",
      "schema": "query.sql",
      "queries": "query.sql"
    }
   ]
}

Playground URL

https://play.sqlc.dev/p/1f6e668fb3015032c9e28259e03ef5a8d0a045a543d6b367f23642c424116a44

What operating system are you using?

Linux

What database engines are you using?

MySQL

What type of code are you generating?

Go

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