tank_tests/
other.rs

1use std::{pin::pin, sync::LazyLock};
2use tank::{
3    DataSet, Entity, Executor, cols,
4    stream::{StreamExt, TryStreamExt},
5};
6use tokio::sync::Mutex;
7
8static MUTEX: LazyLock<Mutex<()>> = LazyLock::new(|| Mutex::new(()));
9
10#[derive(Debug, Entity, PartialEq)]
11pub struct ATable {
12    #[tank(primary_key)]
13    a_column: String,
14}
15
16pub async fn other<E: Executor>(executor: &mut E) {
17    let _lock = MUTEX.lock().await;
18
19    // Setup
20    ATable::drop_table(executor, true, false)
21        .await
22        .expect("Failed to drop ATable table");
23    ATable::create_table(executor, true, true)
24        .await
25        .expect("Failed to create ATable table");
26    ATable::insert_one(
27        executor,
28        &ATable {
29            a_column: "".into(),
30        },
31    )
32    .await
33    .expect("Could not save a row");
34
35    // SELECT NULL
36    let value = pin!(
37        ATable::table()
38            .select(executor, cols!(NULL), true, None)
39            .map_ok(|v| v.values.into_iter().nth(0).unwrap())
40    )
41    .next()
42    .await
43    .expect("No result returned from the stream")
44    .expect("Could not query for NULL");
45    assert!(value.is_null());
46}