executemany should work with "insert ... on update
(self)
| 442 | self._verify_records(data) |
| 443 | |
| 444 | def test_issue_288(self): |
| 445 | """executemany should work with "insert ... on update""" |
| 446 | conn = self.connect() |
| 447 | cursor = conn.cursor() |
| 448 | data = [(0, "bob", 21, 123), (1, "jim", 56, 45), (2, "fred", 100, 180)] |
| 449 | cursor.executemany( |
| 450 | """insert |
| 451 | into bulkinsert (id, name, |
| 452 | age, height) |
| 453 | values (%s, |
| 454 | %s , %s, |
| 455 | %s ) on duplicate key update |
| 456 | age = values(age) |
| 457 | """, |
| 458 | data, |
| 459 | ) |
| 460 | self.assertEqual( |
| 461 | cursor._executed.strip(), |
| 462 | bytearray( |
| 463 | b"""insert |
| 464 | into bulkinsert (id, name, |
| 465 | age, height) |
| 466 | values (0, |
| 467 | 'bob' , 21, |
| 468 | 123 ),(1, |
| 469 | 'jim' , 56, |
| 470 | 45 ),(2, |
| 471 | 'fred' , 100, |
| 472 | 180 ) on duplicate key update |
| 473 | age = values(age)""" |
| 474 | ), |
| 475 | ) |
| 476 | cursor.execute("commit") |
| 477 | self._verify_records(data) |
nothing calls this directly
no test coverage detected