Open erojano opened 1 year ago
Hi @erojano!
Yes this is a good one and makes sense to me, I'm totally in for that! Do you want to give it a try? I'm not sure if I can find time for adding this in near future.
Yeah, I'll be happy to contribute; I just have to make some time. I think tables-to-go is a "must have"; this is big. 💪🏼
Need it too! Will it be implemented?
I'm afraid it is not as easy as it looks like. At least for MySQL I checked real quick on how to get the column definitions and it seems all we can get here is the CREATE statement the view was created with - https://dev.mysql.com/doc/refman/8.0/en/information-schema-views-table.html
Same applies for PG: https://www.postgresql.org/docs/current/view-pg-views.html
It seems it boils down to be the same request as in #1 - parsing a SELECT-query string to create the table&column definitions from it rather than querying INFORMATION_SCHEMA tables. This would require a sophisticated SQL parser library (per database?) and much more time to integrate & implement this feature.
I'm open to discuss the options, but not sure if I can find time to actively implement it.
I need this kind of feature for my other project, so I have created https://github.com/mpkondrashin/views and used it to generate https://github.com/mpkondrashin/smsdb this code is not fully tested, it is PoC, I would say, but it shows that generating go structures for MySQL views is possible.
This is a kind feature request :)
Is there any way of generate structs also of database views?
Thank you.