sqlboiler
sqlboiler copied to clipboard
[Feature] Table and Column Comments
It would be helpful to pull comments from tables and column, and if they are present, write them as comments in the generated go code. This will help with documentation and follow the design goal: the schema is the source of truth.
If this is interesting, I can help with the mysql implementation.
Would appreciate this feature very much.
Assuming the above is acceptable, I also have plans for how to add support for PostgreSQL table comments.
Is anyone still working on this? I'd be happy to send an updated patch in the next few days.
@vladvelici I don't believe anyone has done anything with it that I'm aware of.
I've sent a PR. There are some tests failing, seems like for mysql. I can look at that if you think I'm on the right path for postgres.
https://github.com/volatiletech/sqlboiler/pull/807
I did a bit of work on adding table/struct comments too, the problem I ran in to is that the drivers.Constructor
interface defines a TableNames
method:
TableNames(schema string, whitelist, blacklist []string) ([]string, error)
Modifying this to also return the comments isn't possible with this function signature.
Are these interfaces considered stable? I can't add a new method to this interface without breaking users of this interface.
Otherwise I can add an optional TableInfo
or TableCapabilities
interface, which is a little bit uglier but maintains compatibility.
This also applies to ViewConstructor.ViewNames
.
Here's a basic patch btw: https://github.com/schoolyear/sqlboiler/commit/fea0e6b76ab8b5bbc7601b92cf7c69c2d0a8c5d5
It's compatible, but has some duplication in TableNames()
and Tables()
, but it's not too bad and a bit hard to avoid.
I'll wait for some feedback on what patch you want to take, but as soon as that's clear I'll add a test, maybe cleanup a few things, and submit a PR.
This looks alright. Would you be able to extend this to also include column comments?
I just saw this MR https://github.com/volatiletech/sqlboiler/pull/807
It seems that column comments are already included.