Skip to content

Add COMMENT ON support for views #2241

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

Closed
mdigger opened this issue Apr 28, 2023 · 5 comments · Fixed by #2249
Closed

Add COMMENT ON support for views #2241

mdigger opened this issue Apr 28, 2023 · 5 comments · Fixed by #2249
Labels
📚 postgresql enhancement New feature or request question Further information is requested

Comments

@mdigger
Copy link

mdigger commented Apr 28, 2023

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

@mdigger mdigger added enhancement New feature or request triage New issues that hasn't been reviewed labels Apr 28, 2023
@kyleconroy kyleconroy removed the triage New issues that hasn't been reviewed label Apr 28, 2023
@kyleconroy
Copy link
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

@kyleconroy kyleconroy added the question Further information is requested label Apr 28, 2023
@mdigger
Copy link
Author

mdigger commented Apr 28, 2023

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

How is it done for tables... :)

@kyleconroy
Copy link
Collaborator

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

@mdigger
Copy link
Author

mdigger commented Apr 28, 2023

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.

@kyleconroy
Copy link
Collaborator

Indeed there isn't!

@kyleconroy kyleconroy reopened this Apr 28, 2023
@kyleconroy kyleconroy changed the title Use comment on view Add COMMENT ON support for views Apr 28, 2023
orisano added a commit to orisano/sqlc that referenced this issue May 2, 2023
kyleconroy added a commit that referenced this issue Jun 6, 2023
* feat: add supporting COMMENT ON VIEW

close #2241

* test: Add tests for COMMENT ON VIEW

---------

Co-authored-by: Kyle Conroy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 postgresql enhancement New feature or request question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants