Parameterised frozen queries #186
Unanswered
peterswords
asked this question in
Q&A
Replies: 1 comment 3 replies
-
Hi Peter. Currently frozen queries can't be modified. An example use case is getting the latest posts for a blog, as the query never changes: LATEST_POSTS = Post.objects().order_by(Post.created_on).where(Post.draft == false).limit(5).freeze()
await LATEST_POSTS.run() However, we can't do something like: await LATEST_POSTS.where(Post.created_by = some_user).run() It might be something we can add in the future. The underlying database adapter (asyncpg) does have support for prepared statements, so it's certainly possible. https://magicstack.github.io/asyncpg/current/api/index.html#prepared-statements |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In many SQL frameworks (e.g. ODBC, JDBC) you have the concept of a PreparedStatement which is an SQL statement that is precompiled for efficiency. The statement can contain placeholders which are provided by the caller before the statement is executed.
Do Piccolo frozen queries have anything likes this? Can I freeze a query but still provide values for, e.g. a WHERE clause, on the frozen query at runtime?
Beta Was this translation helpful? Give feedback.
All reactions