Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

SQLC does not infer nullability for subqueries in view SELECT #4262

Open
@lookeey

Description

Version

1.30.0

What happened?

I have a DB with a view like so:

CREATE VIEW schema.vw_myview AS
 SELECT
 p.id AS id_produto,
 (SELECT i.name
 FROM public.tb_ibpt i
 WHERE ((i.code)::text = (p.ncm)::text)
 LIMIT 1) AS description,
...

I would expect that selecting the description column in the resulting vw_myview would create a nullable type in the SQLC generated struct, but instead a string field is created. So when there are no matches in the subquery, there is a scan error.

Relevant log output

Database schema

SQL queries

Configuration

version: "2"
sql:
 - engine: postgresql
 schema: generated.sql
 queries:
 - queries
 gen:
 go:
 package: sqls_erp
 sql_package: "pgx/v5"
 out: ../internal/sqls/sql_erp
 emit_json_tags: true

Playground URL

No response

What operating system are you using?

Linux

What database engines are you using?

PostgreSQL

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

        AltStyle によって変換されたページ (->オリジナル) /