Add integration test for MySQL enums type

This commit is contained in:
BohuTANG 2020-06-27 09:22:01 +08:00
parent f609fd34f7
commit a13d201991

View File

@ -16,6 +16,7 @@ create_table_sql_template = """
`name` varchar(50) NOT NULL, `name` varchar(50) NOT NULL,
`age` int NOT NULL default 0, `age` int NOT NULL default 0,
`money` int NOT NULL default 0, `money` int NOT NULL default 0,
`source` enum('IP','URL') DEFAULT 'IP',
PRIMARY KEY (`id`)) ENGINE=InnoDB; PRIMARY KEY (`id`)) ENGINE=InnoDB;
""" """
@ -114,6 +115,19 @@ def test_table_function(started_cluster):
conn.close() conn.close()
def test_enum_type(started_cluster):
table_name = 'test_enum_type'
conn = get_mysql_conn()
create_mysql_table(conn, table_name)
node1.query('''
CREATE TABLE {}(id UInt32, name String, age UInt32, money UInt32, source Enum8('IP' = 1, 'URL' = 2)) ENGINE = MySQL('mysql1:3306', 'clickhouse', '{}', 'root', 'clickhouse', 1);
'''.format(table_name, table_name))
node1.query("INSERT INTO {}(id, name, age, money) VALUES (1,'name',0, 0)".format(table_name))
assert node1.query("SELECT source FROM {} LIMIT 1".format(table_name)).rstrip() == 'IP'
conn.close()
def get_mysql_conn(): def get_mysql_conn():
conn = pymysql.connect(user='root', password='clickhouse', host='127.0.0.1', port=3308) conn = pymysql.connect(user='root', password='clickhouse', host='127.0.0.1', port=3308)
return conn return conn