executemany should work with "insert ... on update
(self)
| 421 | self._verify_records(data) |
| 422 | |
| 423 | def test_issue_288(self): |
| 424 | """executemany should work with "insert ... on update""" |
| 425 | conn = self.connect() |
| 426 | cursor = conn.cursor() |
| 427 | data = [(0, "bob", 21, 123), (1, "jim", 56, 45), (2, "fred", 100, 180)] |
| 428 | cursor.executemany( |
| 429 | """insert |
| 430 | into bulkinsert (id, name, |
| 431 | age, height) |
| 432 | values (%s, |
| 433 | %s , %s, |
| 434 | %s ) on duplicate key update |
| 435 | age = values(age) |
| 436 | """, |
| 437 | data, |
| 438 | ) |
| 439 | self.assertEqual( |
| 440 | cursor._executed.strip(), |
| 441 | bytearray( |
| 442 | b"""insert |
| 443 | into bulkinsert (id, name, |
| 444 | age, height) |
| 445 | values (0, |
| 446 | 'bob' , 21, |
| 447 | 123 ),(1, |
| 448 | 'jim' , 56, |
| 449 | 45 ),(2, |
| 450 | 'fred' , 100, |
| 451 | 180 ) on duplicate key update |
| 452 | age = values(age)""" |
| 453 | ), |
| 454 | ) |
| 455 | cursor.execute("commit") |
| 456 | self._verify_records(data) |
nothing calls this directly
no test coverage detected