diff --git a/cassandra/cqltypes.py b/cassandra/cqltypes.py index bf48724b..d023350b 100644 --- a/cassandra/cqltypes.py +++ b/cassandra/cqltypes.py @@ -439,6 +439,8 @@ cql_time_formats = ( '%Y-%m-%d' ) +_have_warned_about_timestamps = False + class DateType(_CassandraType): typename = 'timestamp' @@ -482,6 +484,20 @@ class DateType(_CassandraType): if type(v) not in _number_types: raise TypeError('DateType arguments must be a datetime or timestamp') + if not _have_warned_about_timestamps: + global _have_warned_about_timestamps + _have_warned_about_timestamps = True + warnings.warn("timestamp columns in Cassandra hold a number of " + "milliseconds since the unix epoch. Currently, when executing " + "prepared statements, this driver multiplies timestamp " + "values by 1000 so that the result of time.time() " + "can be used directly. However, the driver cannot " + "match this behavior for non-prepared statements, " + "so the 2.0 version of the driver will no longer multiply " + "timestamps by 1000. It is suggested that you simply use " + "datetime.datetime objects for 'timestamp' values to avoid " + "any ambiguity and to guarantee a smooth upgrade of the " + "driver.") converted = v * 1e3 return int64_pack(long(converted))