Skip to content

Commit e52728a

Browse files
committed
Do not cast z and m to None when writting to ewkb
1 parent 0090627 commit e52728a

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

postgis/point.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ def from_ewkb_body(cls, reader, srid=None):
5555
def write_ewkb_body(self, writer):
5656
writer.write_double(self.x)
5757
writer.write_double(self.y)
58-
if self.z:
58+
if self.z is not None:
5959
writer.write_double(self.z)
60-
if self.m:
60+
if self.m is not None:
6161
writer.write_double(self.m)
6262

6363
@property

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def list_modules(dirname):
4646
cmdclass = {'build_ext': build_ext}
4747

4848

49-
VERSION = (1, 0, 1)
49+
VERSION = (1, 0, 2)
5050

5151
setup(
5252
name='postgis',

tests/psycopg/test_point.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,16 @@ def test_point_should_round(cursor, expected):
1515
assert geom.coords == expected
1616

1717

18-
def test_point_with_geography_column(cursor):
18+
@pytest.mark.parametrize('expected', [
19+
(1, -2, 3),
20+
(-1.123456789, 2.987654321, 231),
21+
(1, -2, 0),
22+
])
23+
def test_point_geography_column_should_round(cursor, expected):
1924
cursor.execute('CREATE TABLE geography_point ("geom" geography(PointZ))')
20-
params = [Point(1, 2, 3, srid=4326)]
25+
params = [Point(*expected, srid=4326)]
2126
cursor.execute('INSERT INTO geography_point (geom) VALUES (%s)', params)
2227
cursor.execute('SELECT geom FROM geography_point WHERE geom=%s', params)
2328
geom = cursor.fetchone()[0]
24-
assert geom.coords == (1, 2, 3)
29+
assert geom.coords == expected
2530
cursor.execute('DROP TABLE geography_point')

0 commit comments

Comments
 (0)