You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am implementing a kind of dynamic table feature, users can create any tables and columns as they want, so the backend needs to generate the sql dynamically.
When I try the following the code
let sql_st = format!("select * from {} where {}",
table,&join_cond_parts(cond_parts));let row_stream = sqlx::query(&sql_st).fetch(&self.db);
, the compiler complains this cast requires that 'sql_st' is borrowed for 'static'.
The only solution I can come up is to put the sql_st into a staitc container like map, vec, etc, but it's not thread-efficiency since it requires a lock to achieve querying.
Anyway that I can get the stream query result without a non-static lifetime &str?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am implementing a kind of dynamic table feature, users can create any tables and columns as they want, so the backend needs to generate the sql dynamically.
When I try the following the code
, the compiler complains this
cast requires that 'sql_st' is borrowed for 'static'
.The only solution I can come up is to put the
sql_st
into astaitc container
likemap, vec, etc
, but it's not thread-efficiency since it requires a lock to achieve querying.Anyway that I can get the stream query result without a non-static lifetime
&str
?Thank you!
Beta Was this translation helpful? Give feedback.
All reactions