Skip to content

Commit b43ddd4

Browse files
committed
Also register for geography column
1 parent 74ba8cc commit b43ddd4

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

postgis/geometry.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,8 @@ def register(cursor):
6262
oid = cursor.description[0][1]
6363
GEOMETRY = _ext.new_type((oid, ), "GEOMETRY", Geometry.from_ewkb)
6464
_ext.register_type(GEOMETRY)
65+
66+
cursor.execute("SELECT NULL::geography")
67+
oid = cursor.description[0][1]
68+
GEOGRAPHY = _ext.new_type((oid, ), "GEOGRAPHY", Geometry.from_ewkb)
69+
_ext.register_type(GEOGRAPHY)

tests/test_point.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,13 @@ def test_point_with_z_can_be_unpacked_to_dict():
9090
assert data['y'] == 2
9191
assert data['z'] == 3
9292
assert len(data) == 3
93+
94+
95+
def test_point_with_geography_column(cursor):
96+
cursor.execute('CREATE TABLE geography_point ("geom" geography(PointZ))')
97+
params = [Point(1, 2, 3, srid=4326)]
98+
cursor.execute('INSERT INTO geography_point (geom) VALUES (%s)', params)
99+
cursor.execute('SELECT geom FROM geography_point WHERE geom=%s', params)
100+
geom = cursor.fetchone()[0]
101+
assert geom.coords == (1, 2, 3)
102+
cursor.execute('DROP TABLE geography_point')

0 commit comments

Comments
 (0)