mirror of
https://github.com/django/django.git
synced 2025-09-26 20:19:16 +00:00
Made NumPoints raise TypeError on MySQL when it's used on fields besides LineStringField.
This commit is contained in:
parent
3215bc98fe
commit
5d28fef8f9
2 changed files with 9 additions and 5 deletions
|
@ -304,11 +304,14 @@ class GISFunctionsTests(TestCase):
|
|||
Track.objects.create(name='Foo', line=LineString(coords))
|
||||
qs = Track.objects.annotate(num_points=functions.NumPoints('line'))
|
||||
self.assertEqual(qs.first().num_points, 2)
|
||||
if spatialite or mysql:
|
||||
# SpatiaLite and MySQL can only count points on LineStrings
|
||||
mpoly_qs = Country.objects.annotate(num_points=functions.NumPoints('mpoly'))
|
||||
if not connection.features.supports_num_points_poly:
|
||||
msg = 'NumPoints can only operate on LineString content on this database.'
|
||||
with self.assertRaisesMessage(TypeError, msg):
|
||||
list(mpoly_qs)
|
||||
return
|
||||
|
||||
for c in Country.objects.annotate(num_points=functions.NumPoints('mpoly')):
|
||||
for c in mpoly_qs:
|
||||
self.assertEqual(c.mpoly.num_points, c.num_points)
|
||||
|
||||
if not oracle:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue