PageRenderTime 146ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/django/contrib/gis/db/backends/oracle/compiler.py

https://code.google.com/p/mango-py/
Python | 44 lines | 27 code | 7 blank | 10 comment | 4 complexity | 3ea27f66ed9fb3228f31105bba39faf1 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. from django.contrib.gis.db.models.sql.compiler import GeoSQLCompiler as BaseGeoSQLCompiler
  2. from django.db.backends.oracle import compiler
  3. SQLCompiler = compiler.SQLCompiler
  4. class GeoSQLCompiler(BaseGeoSQLCompiler, SQLCompiler):
  5. pass
  6. class SQLInsertCompiler(compiler.SQLInsertCompiler, GeoSQLCompiler):
  7. def placeholder(self, field, val):
  8. if field is None:
  9. # A field value of None means the value is raw.
  10. return val
  11. elif hasattr(field, 'get_placeholder'):
  12. # Some fields (e.g. geo fields) need special munging before
  13. # they can be inserted.
  14. ph = field.get_placeholder(val, self.connection)
  15. if ph == 'NULL':
  16. # If the placeholder returned is 'NULL', then we need to
  17. # to remove None from the Query parameters. Specifically,
  18. # cx_Oracle will assume a CHAR type when a placeholder ('%s')
  19. # is used for columns of MDSYS.SDO_GEOMETRY. Thus, we use
  20. # 'NULL' for the value, and remove None from the query params.
  21. # See also #10888.
  22. param_idx = self.query.columns.index(field.column)
  23. params = list(self.query.params)
  24. params.pop(param_idx)
  25. self.query.params = tuple(params)
  26. return ph
  27. else:
  28. # Return the common case for the placeholder
  29. return '%s'
  30. class SQLDeleteCompiler(compiler.SQLDeleteCompiler, GeoSQLCompiler):
  31. pass
  32. class SQLUpdateCompiler(compiler.SQLUpdateCompiler, GeoSQLCompiler):
  33. pass
  34. class SQLAggregateCompiler(compiler.SQLAggregateCompiler, GeoSQLCompiler):
  35. pass
  36. class SQLDateCompiler(compiler.SQLDateCompiler, GeoSQLCompiler):
  37. pass