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

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

Closed
HenkVanMaanen opened this issue Jan 20, 2022 · 0 comments · Fixed by #1404
Closed

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

HenkVanMaanen opened this issue Jan 20, 2022 · 0 comments · Fixed by #1404
Labels

Comments

@HenkVanMaanen
Copy link

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

@HenkVanMaanen HenkVanMaanen added bug Something isn't working triage New issues that hasn't been reviewed labels Jan 20, 2022
@kyleconroy kyleconroy added 📚 mysql 💻 linux 🔧 golang and removed triage New issues that hasn't been reviewed labels Jan 26, 2022
dansimau added a commit to dansimau/sqlc that referenced this issue Jan 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants