|
1 |
| -use crate::utils::DeserializeOwnedValue; |
2 | 1 | use crate::utils::{
|
3 | 2 | create_new_session_builder, scylla_supports_tablets, setup_tracing, supports_feature,
|
4 | 3 | unique_keyspace_name, PerformDDL,
|
@@ -27,9 +26,10 @@ use scylla::statement::Consistency;
|
27 | 26 | use scylla_cql::frame::request::query::{PagingState, PagingStateResponse};
|
28 | 27 | use scylla_cql::serialize::row::{SerializeRow, SerializedValues};
|
29 | 28 | use scylla_cql::serialize::value::SerializeValue;
|
30 |
| -use scylla_cql::value::{CqlVarint, Row}; |
| 29 | +use scylla_cql::value::Row; |
| 30 | +use std::collections::BTreeSet; |
31 | 31 | use std::collections::{BTreeMap, HashMap};
|
32 |
| -use std::collections::{BTreeSet, HashSet}; |
| 32 | +use std::collections::HashSet; |
33 | 33 | use std::sync::atomic::{AtomicBool, Ordering};
|
34 | 34 | use std::sync::{Arc, Mutex};
|
35 | 35 | use tokio::net::TcpListener;
|
@@ -2854,70 +2854,6 @@ async fn test_manual_primary_key_computation() {
|
2854 | 2854 | }
|
2855 | 2855 | }
|
2856 | 2856 |
|
2857 |
| -/// ScyllaDB does not distinguish empty collections from nulls. That is, INSERTing an empty collection |
2858 |
| -/// is equivalent to nullifying the corresponding column. |
2859 |
| -/// As pointed out in [#1001](https://github.com/scylladb/scylla-rust-driver/issues/1001), it's a nice |
2860 |
| -/// QOL feature to be able to deserialize empty CQL collections to empty Rust collections instead of |
2861 |
| -/// `None::<RustCollection>`. This test checks that. |
2862 |
| -#[tokio::test] |
2863 |
| -async fn test_deserialize_empty_collections() { |
2864 |
| - // Setup session. |
2865 |
| - let ks = unique_keyspace_name(); |
2866 |
| - let session = create_new_session_builder().build().await.unwrap(); |
2867 |
| - session.ddl(format!("CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}", ks)).await.unwrap(); |
2868 |
| - session.use_keyspace(&ks, true).await.unwrap(); |
2869 |
| - |
2870 |
| - async fn deserialize_empty_collection< |
2871 |
| - Collection: Default + DeserializeOwnedValue + SerializeValue, |
2872 |
| - >( |
2873 |
| - session: &Session, |
2874 |
| - collection_name: &str, |
2875 |
| - collection_type_params: &str, |
2876 |
| - ) -> Collection { |
2877 |
| - // Create a table for the given collection type. |
2878 |
| - let table_name = "test_empty_".to_owned() + collection_name; |
2879 |
| - let query = format!( |
2880 |
| - "CREATE TABLE {} (n int primary key, c {}<{}>)", |
2881 |
| - table_name, collection_name, collection_type_params |
2882 |
| - ); |
2883 |
| - session.ddl(query).await.unwrap(); |
2884 |
| - |
2885 |
| - // Populate the table with an empty collection, effectively inserting null as the collection. |
2886 |
| - session |
2887 |
| - .query_unpaged( |
2888 |
| - format!("INSERT INTO {} (n, c) VALUES (?, ?)", table_name,), |
2889 |
| - (0, Collection::default()), |
2890 |
| - ) |
2891 |
| - .await |
2892 |
| - .unwrap(); |
2893 |
| - |
2894 |
| - let query_rows_result = session |
2895 |
| - .query_unpaged(format!("SELECT c FROM {}", table_name), ()) |
2896 |
| - .await |
2897 |
| - .unwrap() |
2898 |
| - .into_rows_result() |
2899 |
| - .unwrap(); |
2900 |
| - let (collection,) = query_rows_result.first_row::<(Collection,)>().unwrap(); |
2901 |
| - |
2902 |
| - // Drop the table |
2903 |
| - collection |
2904 |
| - } |
2905 |
| - |
2906 |
| - let list = deserialize_empty_collection::<Vec<i32>>(&session, "list", "int").await; |
2907 |
| - assert!(list.is_empty()); |
2908 |
| - |
2909 |
| - let set = deserialize_empty_collection::<HashSet<i64>>(&session, "set", "bigint").await; |
2910 |
| - assert!(set.is_empty()); |
2911 |
| - |
2912 |
| - let map = deserialize_empty_collection::<HashMap<bool, CqlVarint>>( |
2913 |
| - &session, |
2914 |
| - "map", |
2915 |
| - "boolean, varint", |
2916 |
| - ) |
2917 |
| - .await; |
2918 |
| - assert!(map.is_empty()); |
2919 |
| -} |
2920 |
| - |
2921 | 2857 | #[cfg(cassandra_tests)]
|
2922 | 2858 | #[tokio::test]
|
2923 | 2859 | async fn test_vector_type_metadata() {
|
|
0 commit comments