Ticket #16778: postgis-adapter-2.patch
File postgis-adapter-2.patch, 1.2 KB (added by , 13 years ago) |
---|
-
django/contrib/gis/db/backends/postgis/adapter.py
old new 12 12 # the adaptor) and the SRID from the geometry. 13 13 self.ewkb = str(geom.ewkb) 14 14 self.srid = geom.srid 15 self._adapter = Binary(self.ewkb) 15 16 16 17 def __conform__(self, proto): 17 18 # Does the given protocol conform to what Psycopg2 expects? … … 26 27 def __str__(self): 27 28 return self.getquoted() 28 29 30 def prepare(self, conn): 31 # Pass the connection to the adapter: this allows escaping the binary 32 # in the style required by the server's standard_conforming_string setting. 33 self._adapter.prepare(conn) 34 29 35 def getquoted(self): 30 36 "Returns a properly quoted string for use in PostgreSQL/PostGIS." 31 # Want to use WKB, so wrap with psycopg2 Binary() to quote properly.32 return 'ST_GeomFromEWKB( E%s)' % Binary(self.ewkb)37 # psycopg will figure out whether to use E'\\000' or '\000' 38 return 'ST_GeomFromEWKB(%s)' % self._adapter.getquoted() 33 39 34 40 def prepare_database_save(self, unused): 35 41 return self