5

I want to run a nested query in sqlx. Here's what I've tried:

sqlx::query_as!(NseData, "select * from nse_data  where trading_day = (select max(trading_day) from nse_data)").fetch_one(&app_context.db_connection).await?;

But it gives me the following error...

error[E0658]: attributes on expressions are experimental
  --> db/src/nse_data.rs:30:9
   |
30 |         sqlx::query_as!(NseData, "select * from nse_data  where trading_day = (select max(trading_day) from nse_data)").await?
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
maxcountryman
  • 1,562
  • 1
  • 24
  • 51
Asnim P Ansari
  • 1,932
  • 1
  • 18
  • 41

0 Answers0