feat(compiler): Support subqueries in the FROM clause
issue #2989, #2400 and probably others
This is without https://github.com/sqlc-dev/sqlc/pull/3220 so we can separate which test failures are caused by which PR.
I've added a fix for unnamed subqueries. That panicked at HEAD and my branch, and works now :)
@Jille, I think the reason why https://github.com/sqlc-dev/sqlc/pull/3322/commits/7d1b0c648ee30d22d698109bb2e229303043494e was required is because this test uses an active database to perform type inference for the query. All tests that use the managed-db config mutate the config to connect to the DB:
https://github.com/sqlc-dev/sqlc/blob/e8405b5bb25c7d612af244fc3958f8f3f7bdc4a0/internal/endtoend/endtoend_test.go#L121-L144
Here is where analysis is performed for columns that are not part of a table:
https://github.com/sqlc-dev/sqlc/blob/caaaacc6faaec2ab893c24328cad260b6a68c6f8/internal/engine/postgresql/analyzer/analyze.go#L272-L288
Notice that notNull is always false in this block. So, for people who do use this setup, the CI output would match this output. I believe this is the reason for the difference between your local sqlc generate output and the CI output, but I'm not sure what can be changed here to allow this analyzer to infer the nullability of this column.