def test_datetime_values(self):
""" Tests for CASSANDRA-9399, check tables with date and time values"""
self.cluster.populate(1)
self.cluster.start(wait_for_binary_proto=True)
node1, = self.cluster.nodelist()
stdout, stderr = self.run_cqlsh(node1, cmds="""
CREATE KEYSPACE datetime_checks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
USE datetime_checks;
CREATE TABLE values (d date, t time, PRIMARY KEY (d, t));
INSERT INTO values (d, t) VALUES ('9800-12-31', '23:59:59.999999999');
INSERT INTO values (d, t) VALUES ('2015-05-14', '16:30:00.555555555');
INSERT INTO values (d, t) VALUES ('1582-1-1', '00:00:00.000000000');
INSERT INTO values (d, t) VALUES ('%d-1-1', '00:00:00.000000000');
INSERT INTO values (d, t) VALUES ('%d-1-1', '01:00:00.000000000');
INSERT INTO values (d, t) VALUES ('%d-1-1', '02:00:00.000000000');
INSERT INTO values (d, t) VALUES ('%d-1-1', '03:00:00.000000000')"""
% (datetime.MINYEAR - 1, datetime.MINYEAR, datetime.MAXYEAR, datetime.MAXYEAR + 1,))
# outside the MIN and MAX range it should print the number of days from the epoch
self.assertEqual(len(stderr), 0, "Failed to execute cqlsh: {}".format(stderr))
self.verify_output("select * from datetime_checks.values", node1, """
d | t
------------+--------------------
-719528 | 00:00:00.000000000
9800-12-31 | 23:59:59.999999999
0001-01-01 | 01:00:00.000000000
1582-01-01 | 00:00:00.000000000
2932897 | 03:00:00.000000000
9999-01-01 | 02:00:00.000000000
2015-05-14 | 16:30:00.555555555
""")
self.verify_output("DESCRIBE TABLE datetime_checks.values", node1, """
CREATE TABLE datetime_checks.values (
d date,
t time,
PRIMARY KEY (d, t)
""")
评论列表
文章目录