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

https://code.google.com/p/mango-py/ · Python · 32 lines · 22 code · 7 blank · 3 comment · 2 complexity · 23648eb790a0776fcfcccf354d19c891 MD5 · raw file

  1. from django.db.backends.util import typecast_timestamp
  2. from django.db.models.sql import compiler
  3. from django.db.models.sql.constants import MULTI
  4. from django.contrib.gis.db.models.sql.compiler import GeoSQLCompiler as BaseGeoSQLCompiler
  5. SQLCompiler = compiler.SQLCompiler
  6. class GeoSQLCompiler(BaseGeoSQLCompiler, SQLCompiler):
  7. pass
  8. class SQLInsertCompiler(compiler.SQLInsertCompiler, GeoSQLCompiler):
  9. pass
  10. class SQLDeleteCompiler(compiler.SQLDeleteCompiler, GeoSQLCompiler):
  11. pass
  12. class SQLUpdateCompiler(compiler.SQLUpdateCompiler, GeoSQLCompiler):
  13. pass
  14. class SQLAggregateCompiler(compiler.SQLAggregateCompiler, GeoSQLCompiler):
  15. pass
  16. class SQLDateCompiler(compiler.SQLDateCompiler, GeoSQLCompiler):
  17. """
  18. This is overridden for GeoDjango to properly cast date columns, see #16757.
  19. """
  20. def results_iter(self):
  21. offset = len(self.query.extra_select)
  22. for rows in self.execute_sql(MULTI):
  23. for row in rows:
  24. date = typecast_timestamp(str(row[offset]))
  25. yield date