Replies: 1 comment 2 replies
-
I just realized you can't do |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have an AST generated from the DSL I'm working on to take user inputted queries. The AST is ran through a recursive
eval
function that generates the query in SQL.The problem is eval uses
format!()
to put recursive calls to itself in between already existing strings. As far as I can tell, this isn't possible with sqlx. There'sQueryBuilder
but you can only ever push to the end of a builder. So far the solution I've come up with is track how many binds need to be done, generate the string, then loop over that string X amount of times replacing every value with a $1,$2,$3 etc. Once I have the string I can make a newQueryBuilder
with the formatted string and callpush_bind()
however many times I would like.I'm hoping for input from the developers on the direction I should take as it's starting to feel a little hacky. I would also like to know if it's safe to take user input and do a regular old
.push()
with it. If not, does sqlx provide any sensitization methods? I'm pretty sure.push_bind()
can only be used for values.The code in case it's needed:
Beta Was this translation helpful? Give feedback.
All reactions