sqlc generate / vet does not detect outdated INSERT queries after adding a new NOT NULL column #4344
Unanswered
EliottMartinAive
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello !
I would like to describe a case where a schema change can leave older INSERT queries outdated, without sqlc generate or sqlc vet flagging the issue.
Initial migration:
Developer 1 creates the table and writes this query:
Later, another developer adds a new required column:
That developer also adds a new query that includes the new column:
However, they forget to update the original query CreateBabar, which is still used by another service.
So now the old query is effectively invalid at runtime, because it does not provide a value for description, but:
sqlc generate does not flag it
sqlc vet with sqlc/db-prepare does not flag it either
The problem only appears at execution time.
What I would like is a way for sqlc to detect this kind of issue earlier, ideally during generation, vetting, or some schema/query consistency check.
In other words, for INSERT statements, it would be very useful if sqlc could detect when:
a table has a NOT NULL column with no default value
and an existing query no longer inserts that column
This is especially important in multi-service environments, where one service updates migrations and adds new queries, but older queries may still exist in other files or services and become stale.
Is this something that sqlc could support directly, or is there already a recommended workflow to catch this kind of schema drift before runtime?
Beta Was this translation helpful? Give feedback.
All reactions