1
1
use crate :: utils:: {
2
2
create_new_session_builder, scylla_supports_tablets, setup_tracing, supports_feature,
3
- unique_keyspace_name, DeserializeOwnedValue , PerformDDL ,
3
+ unique_keyspace_name, PerformDDL ,
4
4
} ;
5
5
use assert_matches:: assert_matches;
6
6
use futures:: { FutureExt , StreamExt as _, TryStreamExt } ;
@@ -25,10 +25,9 @@ use scylla::routing::partitioner::{calculate_token_for_partition_key, Partitione
25
25
use scylla:: statement:: Consistency ;
26
26
use scylla_cql:: frame:: request:: query:: { PagingState , PagingStateResponse } ;
27
27
use scylla_cql:: serialize:: row:: { SerializeRow , SerializedValues } ;
28
- use scylla_cql:: serialize :: value:: SerializeValue ;
29
- use scylla_cql :: value :: { CqlVarint , Row } ;
28
+ use scylla_cql:: value:: Row ;
29
+ use std :: collections :: BTreeSet ;
30
30
use std:: collections:: HashMap ;
31
- use std:: collections:: { BTreeSet , HashSet } ;
32
31
use std:: sync:: atomic:: { AtomicBool , Ordering } ;
33
32
use std:: sync:: Arc ;
34
33
use tokio:: net:: TcpListener ;
@@ -2530,70 +2529,6 @@ async fn test_manual_primary_key_computation() {
2530
2529
}
2531
2530
}
2532
2531
2533
- /// ScyllaDB does not distinguish empty collections from nulls. That is, INSERTing an empty collection
2534
- /// is equivalent to nullifying the corresponding column.
2535
- /// As pointed out in [#1001](https://github.com/scylladb/scylla-rust-driver/issues/1001), it's a nice
2536
- /// QOL feature to be able to deserialize empty CQL collections to empty Rust collections instead of
2537
- /// `None::<RustCollection>`. This test checks that.
2538
- #[ tokio:: test]
2539
- async fn test_deserialize_empty_collections ( ) {
2540
- // Setup session.
2541
- let ks = unique_keyspace_name ( ) ;
2542
- let session = create_new_session_builder ( ) . build ( ) . await . unwrap ( ) ;
2543
- session. ddl ( format ! ( "CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}}" , ks) ) . await . unwrap ( ) ;
2544
- session. use_keyspace ( & ks, true ) . await . unwrap ( ) ;
2545
-
2546
- async fn deserialize_empty_collection <
2547
- Collection : Default + DeserializeOwnedValue + SerializeValue ,
2548
- > (
2549
- session : & Session ,
2550
- collection_name : & str ,
2551
- collection_type_params : & str ,
2552
- ) -> Collection {
2553
- // Create a table for the given collection type.
2554
- let table_name = "test_empty_" . to_owned ( ) + collection_name;
2555
- let query = format ! (
2556
- "CREATE TABLE {} (n int primary key, c {}<{}>)" ,
2557
- table_name, collection_name, collection_type_params
2558
- ) ;
2559
- session. ddl ( query) . await . unwrap ( ) ;
2560
-
2561
- // Populate the table with an empty collection, effectively inserting null as the collection.
2562
- session
2563
- . query_unpaged (
2564
- format ! ( "INSERT INTO {} (n, c) VALUES (?, ?)" , table_name, ) ,
2565
- ( 0 , Collection :: default ( ) ) ,
2566
- )
2567
- . await
2568
- . unwrap ( ) ;
2569
-
2570
- let query_rows_result = session
2571
- . query_unpaged ( format ! ( "SELECT c FROM {}" , table_name) , ( ) )
2572
- . await
2573
- . unwrap ( )
2574
- . into_rows_result ( )
2575
- . unwrap ( ) ;
2576
- let ( collection, ) = query_rows_result. first_row :: < ( Collection , ) > ( ) . unwrap ( ) ;
2577
-
2578
- // Drop the table
2579
- collection
2580
- }
2581
-
2582
- let list = deserialize_empty_collection :: < Vec < i32 > > ( & session, "list" , "int" ) . await ;
2583
- assert ! ( list. is_empty( ) ) ;
2584
-
2585
- let set = deserialize_empty_collection :: < HashSet < i64 > > ( & session, "set" , "bigint" ) . await ;
2586
- assert ! ( set. is_empty( ) ) ;
2587
-
2588
- let map = deserialize_empty_collection :: < HashMap < bool , CqlVarint > > (
2589
- & session,
2590
- "map" ,
2591
- "boolean, varint" ,
2592
- )
2593
- . await ;
2594
- assert ! ( map. is_empty( ) ) ;
2595
- }
2596
-
2597
2532
#[ cfg( cassandra_tests) ]
2598
2533
#[ tokio:: test]
2599
2534
async fn test_vector_type_metadata ( ) {
0 commit comments