You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Query with COUNT() subselect generates bool field instead of int #1042
Field gets invalid type which in my case causes runtime error when scanning into struct: sql: Scan error on column index 6, name "orders_count": sql/driver: couldn't convert 14 into type bool
I also managed to reproduce it in the sqlc playground:
query.sql
CREATETABLEauthors (
id BIGSERIALPRIMARY KEY,
name textNOT NULL,
bio text
);
CREATETABLEbooks (
id BIGSERIALPRIMARY KEY,
author_id BIGSERIALNOT NULLREFERENCES authors(id),
title textNOT NULL
);
-- name: GetAuthorsWithBooksCount :manySELECT*, (
SELECTCOUNT(id) FROM books
WHEREbooks.author_id= id
) AS books_count
FROM authors;
Code generated:
Noticed interesting thing: if i remove AS statement (column alias) it will give this field name Exists
Activity
fr3fou commentedon Jun 25, 2021
Any temporary workaround for this?