#10888 closed (fixed)
Inserting model with GeometryField as None crashes on Oracle
| Reported by: | Jani Tiainen | Owned by: | jbronn |
|---|---|---|---|
| Component: | GIS | Version: | dev |
| Severity: | Keywords: | oracle gis null | |
| Cc: | Matt Boersma | Triage Stage: | Accepted |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
myapp/models.py:
from django.contrib.gis.db import models
class TestModel (models.Model):
loc = models.GeometryField(null=True, blank=True)
objects = models.GeoManager()
If I run code:
>>> from myapp.models import TestModel
>>> t = TestModel()
>>> t.save()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "d:\work\django-trunk\django\db\models\base.py", line 407, in save
self.save_base(force_insert=force_insert, force_update=force_update)
File "d:\work\django-trunk\django\db\models\base.py", line 483, in save_base
result = manager._insert(values, return_id=update_pk)
File "d:\work\django-trunk\django\db\models\manager.py", line 177, in _insert
return insert_query(self.model, values, **kwargs)
File "d:\work\django-trunk\django\db\models\query.py", line 1037, in insert_query
return query.execute_sql(return_id)
File "d:\work\django-trunk\django\db\models\sql\subqueries.py", line 320, in execute_s
cursor = super(InsertQuery, self).execute_sql(None)
File "d:\work\django-trunk\django\db\models\sql\query.py", line 2310, in execute_sql
cursor.execute(sql, params)
File "d:\work\django-trunk\django\db\backends\util.py", line 19, in execute
return self.cursor.execute(sql, params)
File "d:\work\django-trunk\django\db\backends\oracle\base.py", line 433, in execute
raise e
DatabaseError: ORA-00932: inconsistent datatypes: expected MDSYS.SDO_GEOMETRY got CHAR
Attachments (2)
Change History (10)
comment:1 by , 17 years ago
follow-up: 3 comment:2 by , 17 years ago
Quote from Anthony Tuininga on cx-oracle-users list:
This is expected behavior, unfortunately. Oracle requires a type to be
specified and if all you supply is None cx_Oracle has no choice but to
assume something. And CHAR seems the most likely to cause the least
difficulties. cx_Oracle currently has no way of binding in Oracle
object values like MDSYS.SDO_GEOMETRY.
So this is now real problem since you cant have null geometries easily.
by , 17 years ago
| Attachment: | orcl_null_v1.diff added |
|---|
comment:3 by , 17 years ago
| Keywords: | null added |
|---|---|
| Needs tests: | set |
| Owner: | changed from to |
| Triage Stage: | Unreviewed → Design decision needed |
Replying to jtiai:
For the rest of us, this is the thread from the cx_Oracle mailing list.
So this is now real problem since you cant have null geometries easily.
I agree it's a problem. But should we hack GeoDjango, as my attached patch does to just use NULL for the placeholder and omit a parameter? Or should we wait until the real underlying problem cx_Oracle is solved?
Until I'm convinced otherwise, I'm -1 on my own patch because (i) it's a hack, (ii) needs tests and (iii) it does not address other NULL geometry related issues, e.g., UPDATE queries (.update(geom_field=None)).
by , 17 years ago
| Attachment: | orcl_null_v2.diff added |
|---|
comment:4 by , 17 years ago
| Has patch: | set |
|---|---|
| milestone: | → 1.1 |
| Needs tests: | unset |
| Status: | new → assigned |
| Triage Stage: | Design decision needed → Accepted |
Alright, the v2 patch has grown on me and I'm +1 now. Specifically, I just re-enabled the existing null geometry tests for Oracle, .update() queries aren't affected by the problem, and the 'hackishness' only applies for Oracle -- which is par for the course.
comment:5 by , 17 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
comment:6 by , 17 years ago
comment:7 by , 16 years ago
| Cc: | added |
|---|
Further investigation indicates that this is more likely a Bug in cx_Oracle than Geodjango framework.