()
| 971 | |
| 972 | #[tokio::test] |
| 973 | async fn test_view_join_table() -> anyhow::Result<()> { |
| 974 | let db = TestDB::in_memory()?; |
| 975 | |
| 976 | let schema = [("a", AlgebraicType::U8), ("b", AlgebraicType::U8)]; |
| 977 | let (_, v_id) = tests_utils::create_view_for_test(&db, "v", &schema, false)?; |
| 978 | |
| 979 | let schema = [("c", AlgebraicType::U8), ("d", AlgebraicType::U8)]; |
| 980 | let t_id = db.create_table_for_test("t", &schema, &[0.into()])?; |
| 981 | |
| 982 | with_auto_commit(&db, |tx| -> Result<_, DBError> { |
| 983 | db.insert(tx, t_id, &product![0u8, 3u8].to_bsatn_vec().unwrap())?; |
| 984 | db.insert(tx, t_id, &product![1u8, 4u8].to_bsatn_vec().unwrap())?; |
| 985 | tests_utils::insert_into_view(&db, tx, v_id, Some(identity_from_u8(1)), product![0u8, 1u8])?; |
| 986 | tests_utils::insert_into_view(&db, tx, v_id, Some(identity_from_u8(2)), product![1u8, 2u8])?; |
| 987 | Ok(()) |
| 988 | })?; |
| 989 | |
| 990 | let id = identity_from_u8(2); |
| 991 | let auth = AuthCtx::new(Identity::ZERO, id); |
| 992 | |
| 993 | assert_query_results( |
| 994 | db.clone(), |
| 995 | "select t.* from v join t on v.a = t.c", |
| 996 | auth.clone(), |
| 997 | [product![1u8, 4u8]], |
| 998 | ) |
| 999 | .await; |
| 1000 | assert_query_results( |
| 1001 | db.clone(), |
| 1002 | "select v.* from v join t on v.a = t.c", |
| 1003 | auth.clone(), |
| 1004 | [product![1u8, 2u8]], |
| 1005 | ) |
| 1006 | .await; |
| 1007 | assert_query_results( |
| 1008 | db.clone(), |
| 1009 | "select v.* from v join t where v.a = t.c", |
| 1010 | auth.clone(), |
| 1011 | [product![1u8, 2u8]], |
| 1012 | ) |
| 1013 | .await; |
| 1014 | assert_query_results( |
| 1015 | db.clone(), |
| 1016 | "select v.b as b, t.d as d from v join t on v.a = t.c", |
| 1017 | auth.clone(), |
| 1018 | [product![2u8, 4u8]], |
| 1019 | ) |
| 1020 | .await; |
| 1021 | assert_query_results( |
| 1022 | db.clone(), |
| 1023 | "select v.b as b, t.d as d from v join t where v.a = t.c", |
| 1024 | auth.clone(), |
| 1025 | [product![2u8, 4u8]], |
| 1026 | ) |
| 1027 | .await; |
| 1028 | |
| 1029 | Ok(()) |
| 1030 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…