Test binary / geometry types.
(self)
| 456 | cur.executemany(usql, args=(values, values, values)) |
| 457 | |
| 458 | def test_issue_363(self): |
| 459 | """Test binary / geometry types.""" |
| 460 | conn = pymysql.connect(charset="utf8", **self.databases[0]) |
| 461 | self.safe_create_table( |
| 462 | conn, |
| 463 | "issue363", |
| 464 | "CREATE TABLE issue363 ( " |
| 465 | "id INTEGER PRIMARY KEY, geom LINESTRING NOT NULL /*!80003 SRID 0 */, " |
| 466 | "SPATIAL KEY geom (geom)) " |
| 467 | "ENGINE=MyISAM", |
| 468 | ) |
| 469 | |
| 470 | cur = conn.cursor() |
| 471 | query = ( |
| 472 | "INSERT INTO issue363 (id, geom) VALUES" |
| 473 | "(1998, ST_GeomFromText('LINESTRING(1.1 1.1,2.2 2.2)'))" |
| 474 | ) |
| 475 | cur.execute(query) |
| 476 | |
| 477 | # select WKT |
| 478 | query = "SELECT ST_AsText(geom) FROM issue363" |
| 479 | cur.execute(query) |
| 480 | row = cur.fetchone() |
| 481 | self.assertEqual(row, ("LINESTRING(1.1 1.1,2.2 2.2)",)) |
| 482 | |
| 483 | # select WKB |
| 484 | query = "SELECT ST_AsBinary(geom) FROM issue363" |
| 485 | cur.execute(query) |
| 486 | row = cur.fetchone() |
| 487 | self.assertEqual( |
| 488 | row, |
| 489 | ( |
| 490 | b"\x01\x02\x00\x00\x00\x02\x00\x00\x00" |
| 491 | b"\x9a\x99\x99\x99\x99\x99\xf1?" |
| 492 | b"\x9a\x99\x99\x99\x99\x99\xf1?" |
| 493 | b"\x9a\x99\x99\x99\x99\x99\x01@" |
| 494 | b"\x9a\x99\x99\x99\x99\x99\x01@", |
| 495 | ), |
| 496 | ) |
| 497 | |
| 498 | # select internal binary |
| 499 | cur.execute("SELECT geom FROM issue363") |
| 500 | row = cur.fetchone() |
| 501 | # don't assert the exact internal binary value, as it could |
| 502 | # vary across implementations |
| 503 | self.assertTrue(isinstance(row[0], bytes)) |
| 504 | |
| 505 | def test_issue_1206(self): |
| 506 | conn = pymysql.connect(charset="utf8", **self.databases[0]) |
nothing calls this directly
no test coverage detected