Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
So, I'm going to start with the use case.
Our MariaDB database has a lot of KSUIDs, enough that I would be better off writing a tool to automate building the override statements than doing it by hand.
It would be nice if we could just override on type, replace 'binary(20)' with 'github.com/segmentio/ksuid.KSUID' and call it a day.
Sadly, at least the mysql parser turns 'binary(20)' into 'char' well before the override code gets it. In fact, it does this well before any of the sqlc code gets it.
That leaves doing it by column name, but as mentioned above... There are quite a lot of them.
On the other hand, our naming convention is at least vaguely straight forward. The columns all end with _ksuid, so we can automatically detect them.
But why write rules to do this, and have a huge override table, when we can just add globbing support to sqlc?
And so I did that instead. :)
This passes all of the tests, and is reasonably straight forward.