Feature Request: Support for PostgreSQL Temporary Tables
Is your feature request related to a problem? Please describe.
In my queries, I frequently use temporary tables because they are highly performant. However, I miss the type checking provided by the query!() macros when working with these tables.
Describe the solution you'd like
I propose one of the following solutions:
- Allow Chained Queries: Support for queries separated by
;, enabling temporary table creation and usage in a single statement. - Schema Awareness for Temp Tables: Introduce a way to notify the
query!()macro about the existence and schema of a temporary table.
Describe alternatives you've considered Currently, I haven't explored any viable alternatives to achieve the same functionality.
Additional context None at the moment.
Of the two options above I would really prefer schema awareness instead of prepending the temp table creation. While that will work (with IF NOT EXISTS) it will lead to code duplication when using queries using these temporary tables elsewhere.
Specifically I would be glad to allow reusing the query I used for creating the table. Maybe it makes sense to add an optional sqlx::QueryContext parameter which can store a list of SQL queries to execute upfront.
Do you, dear maintainers, think this is a viable way forward? If so, can you guide me on where I should start looking?