Changeset 5535
- Timestamp:
- 06/25/07 09:40:08 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/unicode/django/db/backends/postgresql/base.py
r5531 r5535 7 7 from django.utils.encoding import smart_str, smart_unicode 8 8 from django.db.backends import util 9 from django.db.backends.postgresql.encodings import ENCODING_MAP10 9 try: 11 10 import psycopg as Database … … 65 64 66 65 postgres_version = None 67 client_encoding = None68 66 69 67 class DatabaseWrapper(local): … … 95 93 if set_tz: 96 94 cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE]) 97 cursor.execute("SHOW client_encoding") 98 encoding = ENCODING_MAP[cursor.fetchone()[0]] 99 cursor = UnicodeCursorWrapper(cursor, encoding) 100 global client_encoding 101 if not client_encoding: 102 # We assume the client encoding isn't going to change for random 103 # reasons. 104 Database.register_type(Database.new_type(Database.types[1043].values, 'STRING', typecast_string)) 105 client_encoding = encoding 95 cursor.execute("SET client_encoding to 'UNICODE'") 96 cursor = UnicodeCursorWrapper(cursor, 'utf-8') 106 97 global postgres_version 107 98 if not postgres_version: … … 290 281 if not s: 291 282 return s 292 return smart_unicode(s , client_encoding)283 return smart_unicode(s) 293 284 294 285 # Register these custom typecasts, because Django expects dates/times to be … … 303 294 Database.register_type(Database.new_type((16,), "BOOLEAN", util.typecast_boolean)) 304 295 Database.register_type(Database.new_type((1700,), "NUMERIC", util.typecast_decimal)) 296 Database.register_type(Database.new_type(Database.types[1043].values, 'STRING', typecast_string)) 305 297 306 298 OPERATOR_MAPPING = {
