You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for calling into plugins during code generation. One specific use case I have is to support automatic encryption/decryption of columns. To illustrate, here's very naive proposal:
CREATETABLEauthors (
id BIGSERIALPRIMARY KEY,
name textNOT NULL, -- :encrypted
bio text-- :encrypted
);
Adding the :encrypted annotation and having the encryption plugin enabled would cause sqlc to augment the generated code to look like the below:
The Cipher is be an interface dictated by the plugin that the user would have to provide.
This proposal leaves a lot to answer and is just an example of what we can do with plugins. sqlc having an understanding of the schema and being able to parse annotations (comments) makes it a great place to hook into this automated code for translating. I don't think this is achievable simply with a custom type, since the Cipher needs to be initialized with secret key material to perform the encryption/decryption.
I don't know how exactly you would do a plugin with sqlc. Maybe make it easy to create a custom build of the sqlc CLI, and adding support to the library for code generation hooks. Or, maybe invoking external binaries that communicate over grpc (a pattern in the Go community nowadays), but that could result in a complex protocol and you'd have to describe the AST and in-memory models in protobuf.
I think this could be a really powerful feature though. Curious what your thoughts are.
The text was updated successfully, but these errors were encountered:
I think this could be a really powerful feature though. Curious what your thoughts are.
sqlc isn't at a place where plugins or extensions make sense. Long term, I'd like to have first-class support for extending sqlc to do cool things like encryption. Right now the internals are under heavy development and we haven't even decided on the Go interface between code generation, query parsing, and type checking.
Add support for calling into plugins during code generation. One specific use case I have is to support automatic encryption/decryption of columns. To illustrate, here's very naive proposal:
Adding the
:encrypted
annotation and having theencryption
plugin enabled would cause sqlc to augment the generated code to look like the below:The
Cipher
is be an interface dictated by the plugin that the user would have to provide.This proposal leaves a lot to answer and is just an example of what we can do with plugins.
sqlc
having an understanding of the schema and being able to parse annotations (comments) makes it a great place to hook into this automated code for translating. I don't think this is achievable simply with a custom type, since theCipher
needs to be initialized with secret key material to perform the encryption/decryption.I don't know how exactly you would do a plugin with sqlc. Maybe make it easy to create a custom build of the
sqlc
CLI, and adding support to the library for code generation hooks. Or, maybe invoking external binaries that communicate over grpc (a pattern in the Go community nowadays), but that could result in a complex protocol and you'd have to describe the AST and in-memory models in protobuf.I think this could be a really powerful feature though. Curious what your thoughts are.
The text was updated successfully, but these errors were encountered: