|
33 | 33 | from tests.integration import use_singledc, PROTOCOL_VERSION, execute_until_pass, notprotocolv1, \ |
34 | 34 | BasicSharedKeyspaceUnitTestCase, greaterthancass21, lessthancass30, greaterthanorequalcass3_10 |
35 | 35 | from tests.integration.datatype_utils import update_datatypes, PRIMITIVE_DATATYPES, COLLECTION_TYPES, PRIMITIVE_DATATYPES_KEYS, \ |
36 | | - get_sample, get_collection_sample |
| 36 | + get_sample, get_all_samples, get_collection_sample |
37 | 37 |
|
38 | 38 |
|
39 | 39 | def setup_module(): |
@@ -161,8 +161,30 @@ def test_can_insert_primitive_datatypes(self): |
161 | 161 | for expected, actual in zip(params, results): |
162 | 162 | self.assertEqual(actual, expected) |
163 | 163 |
|
| 164 | + # try the same thing sending one insert at the time |
| 165 | + s.execute("TRUNCATE alltypes;") |
| 166 | + for i, datatype in enumerate(PRIMITIVE_DATATYPES): |
| 167 | + single_col_name = chr(start_index + i) |
| 168 | + single_col_names = ["zz", single_col_name] |
| 169 | + placeholders = ','.join(["%s"] * len(single_col_names)) |
| 170 | + single_columns_string = ', '.join(single_col_names) |
| 171 | + for j, data_sample in enumerate(get_all_samples(datatype)): |
| 172 | + key = i + 1000 * j |
| 173 | + single_params = (key, data_sample) |
| 174 | + s.execute("INSERT INTO alltypes ({0}) VALUES ({1})".format(single_columns_string, placeholders), |
| 175 | + single_params) |
| 176 | + # verify data |
| 177 | + result = s.execute("SELECT {0} FROM alltypes WHERE zz=%s".format(single_columns_string), (key,))[0][1] |
| 178 | + compare_value = data_sample |
| 179 | + if six.PY3: |
| 180 | + import ipaddress |
| 181 | + if isinstance(data_sample, ipaddress.IPv4Address) or isinstance(data_sample, ipaddress.IPv6Address): |
| 182 | + compare_value = str(data_sample) |
| 183 | + self.assertEqual(result, compare_value) |
| 184 | + |
164 | 185 | # try the same thing with a prepared statement |
165 | 186 | placeholders = ','.join(["?"] * len(col_names)) |
| 187 | + s.execute("TRUNCATE alltypes;") |
166 | 188 | insert = s.prepare("INSERT INTO alltypes ({0}) VALUES ({1})".format(columns_string, placeholders)) |
167 | 189 | s.execute(insert.bind(params)) |
168 | 190 |
|
|
0 commit comments