sqlc
sqlc copied to clipboard
Export index information in schema
What do you want to change?
I am using a custom plugin to generate some code like sqlc-gen-go. In the current plugin system, only limited information of schema is provided by plugin.GenerateRequest as a protobuf message. In my case, I would like to utilize index information of tables. Index information is not saved even in models in this repo currently. Is there any policy not to provide index as models or export it in GenerateRequest message? If it's okay to support index, I want to contribute for that.
What database engines need to be changed?
PostgreSQL
What programming language backends need to be changed?
No response
@kazegusuri index information would only be available if sqlc was connected to a running database server. Could you give a few examples of the queries that you'd run against the system tables to get the information that you need?
Thank you for your reply! In my case, I don't use a query to generate code. Instead I would like to generate code from catalog (index information) directly.
I know sqlc generates models from tables and operations on tables from queries. But my plugin generates some basic operations such as insert, update, delete by PK for each model without queries. If index information is available by plugins, they can generate more code by default with using index information.
If I understand correctly, sqlc already parses index statement from DDL and build ast here. However the ast is not populated to catalog here. Once index information is populated into Catalog, we can pass the information by adding it to plugin.GenerateRequest so that plugin can consume the index information.
@kyleconroy How do you think? Can I work on this for this repo?