Parameterizing table names #1305
Unanswered
diamond29
asked this question in
Feature Requests & Ideas
Replies: 1 comment
|
I'm wondering if we could take the same approach as I'd like to either solve this via SQL or by using a real programming language for configuration (something like Skylark). I think a combination of YAML + templates won't scale for larger projecs.
Here's a placeholder Go template that does that. {{range .Tables}}
-- name: List{{.}} :many
SELECT start_at, end_at, and is_deleted FROM {{.}};
{{end}}I agree that this feels fragile, but is likely the solution you'll need to go with in the short-term. |
0 replies
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.
Is there a pattern or any interest in adding native support for parameterizing a table name?
In my database, we have a bunch of existing tables with fields like, start_at, end_at, and is_deleted. There are a lot of queries for different tables that look basically the same based on these fields, and they're repeated for sqlc in each file.
I considered moving this common data to another table, but that requires extra joins/queries at runtime, and for us to migrate our data. We could also write some code to generate the sqlc inputs, but that seems fragile.
Any other ideas?
All reactions