scylladb / scylla-rust-driver

Async CQL driver for Rust, optimized for ScyllaDB!
Apache License 2.0
562 stars 97 forks source link

SerializeCql` is not implemented for `DateTime<Utc> #1042

Open amraaone opened 1 month ago

amraaone commented 1 month ago

Timestamp <—-> value::CqlTimestamp, chrono::DateTime, time::OffsetDateTime

CREATE TABLE mykeyspace.users ( id uuid PRIMARY KEY, created_at timestamp, email text, password text, salt text, username text ) WITH bloom_filter_fp_chance = 0.01 AND caching = {'keys': 'ALL', 'rows_per_partition': 'ALL'} AND comment = '' AND compaction = {'class': 'SizeTieredCompactionStrategy'} AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'} AND crc_check_chance = 1.0 AND default_time_to_live = 0 AND gc_grace_seconds = 864000 AND max_index_interval = 2048 AND memtable_flush_period_in_ms = 0 AND min_index_interval = 128 AND speculative_retry = '99.0PERCENTILE';

that created_at column how to set data? I tried these let now = Utc::now(); let created_at = CqlTimestamp(now.timestamp_millis());

but this Utc::now() is cannot SELECT query works after when row.unwrap panicking my actix project.

how to efficiently set and select?

Lorak-mmk commented 1 month ago

There is such an implementation: https://docs.rs/scylla/latest/scylla/serialize/value/trait.SerializeCql.html#impl-SerializeCql-for-DateTime%3CUtc%3E Did you enable feature chrono on the scylla crate?

Note: in next major release this feature will be renamed to chrono-04.