Skip to content

Add COMMENT ON support for views #2241

Description

@mdigger

What do you want to change?

Use comment to generate model by view.

create view test_view as
    select * from table
    where title is not null;

comment on view test_view is 'Test view';

The generated struct should have a comment before it like so:

// Test view
type TestView struct {
	ID   int64
	Name string
	Bio  sql.NullString
}

No comment currently shows up.

What database engines need to be changed?

PostgreSQL

What programming language backends need to be changed?

Go

Activity

  1. added
    enhancementNew feature or request
    triageNew issues that hasn't been reviewed
    on Apr 28, 2023
  2. removed
    triageNew issues that hasn't been reviewed
    on Apr 28, 2023
  3. kyleconroy commented on Apr 28, 2023

    @kyleconroy
    Collaborator

    @mdigger What exactly would you like to change about how sqlc currently handles this?

    Here's what the code outputs today https://play.sqlc.dev/p/502f584a2eda264a3f28e8e54c206bfe29306d873d8bfdce1c8a91622d0a7f0d

  4. mdigger commented on Apr 28, 2023

    @mdigger
    Author
    // Test view
    type TestView struct {
    	ID   int64
    	Name string
    	Bio  sql.NullString
    }

    How is it done for tables... :)

  5. kyleconroy commented on Apr 28, 2023

    @kyleconroy
    Collaborator

    Please take a look at the link I shared, as sqlc does exactly this.

  6. mdigger commented on Apr 28, 2023

    @mdigger
    Author

    https://play.sqlc.dev/p/47cebd466b443ee4bb73a1986990c5a6a30780c2b2b8903d27e3e51624bbd8df

    // Author table comment
    type Author struct {...}
    
    type TestView struct {...}

    There is no comment on structure TestView in models.go.

  7. kyleconroy commented on Apr 28, 2023

    @kyleconroy
    Collaborator

    Indeed there isn't!

  8. changed the title [-]Use comment on view[/-] [+]Add COMMENT ON support for views[/+] on Apr 28, 2023
  9. added a commit that references this issue on May 2, 2023
    c97e9a9
  10. added a commit that references this issue on Jun 6, 2023
    fcfa8a4
  11. added a commit that references this issue on Oct 13, 2025
    dbc2133
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions