Skip to content

Commit 61c6b56

Browse files
committed
Merge pull request #49 from phispi/master
Added test for MULTIPOLYGON (that fails in 1742946)
2 parents 1742946 + d4ef92d commit 61c6b56

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

_mysql.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,6 +1373,7 @@ _mysql_field_to_python(
13731373
field_type == FIELD_TYPE_BLOB ||
13741374
field_type == FIELD_TYPE_VAR_STRING ||
13751375
field_type == FIELD_TYPE_STRING ||
1376+
field_type == FIELD_TYPE_GEOMETRY ||
13761377
field_type == FIELD_TYPE_BIT) {
13771378
binary = 1;
13781379
}

tests/test_MySQLdb_capabilities.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,35 @@ def test_BIT(self):
9696
finally:
9797
c.execute("drop table if exists test_BIT")
9898

99+
def test_MULTIPOLYGON(self):
100+
c = self.cursor
101+
try:
102+
c.execute("""create table test_MULTIPOLYGON (
103+
id INTEGER PRIMARY KEY,
104+
border MULTIPOLYGON)""")
105+
106+
c.execute(
107+
"insert into test_MULTIPOLYGON (id, border)"
108+
" VALUES (1, GeomFromText('MULTIPOLYGON(((1 1, 1 -1, -1 -1, -1 1, 1 1)),((1 1, 3 1, 3 3, 1 3, 1 1)))'))"
109+
)
110+
111+
c.execute("SELECT id, AsText(border) FROM test_MULTIPOLYGON")
112+
row = c.fetchone()
113+
self.assertEqual(row[0], 1)
114+
self.assertEqual(row[1], b'MULTIPOLYGON(((1 1,1 -1,-1 -1,-1 1,1 1)),((1 1,3 1,3 3,1 3,1 1)))')
115+
116+
c.execute("SELECT id, AsWKB(border) FROM test_MULTIPOLYGON")
117+
row = c.fetchone()
118+
self.assertEqual(row[0], 1)
119+
self.assertNotEqual(len(row[1]), 0)
120+
121+
c.execute("SELECT id, border FROM test_MULTIPOLYGON")
122+
row = c.fetchone()
123+
self.assertEqual(row[0], 1)
124+
self.assertNotEqual(len(row[1]), 0)
125+
finally:
126+
c.execute("drop table if exists test_MULTIPOLYGON")
127+
99128
def test_bug_2671682(self):
100129
from MySQLdb.constants import ER
101130
try:

0 commit comments

Comments
 (0)