Commits

glencoates  committed 54e07af

Adding UUID support for postgresql default values so that they
are properly escaped as strings before being interpolated into
the raw SQL.

  • Participants
  • Parent commits 738417d

Comments (0)

Files changed (1)

File south/db/postgresql_psycopg2.py

-
 from django.db import connection, models
 from south.db import generic
 
     """
     PsycoPG2 implementation of database operations.
     """
-    
+
     backend_name = "postgres"
 
     @generic.copy_column_constraints
         "Rename an index individually"
         generic.DatabaseOperations.rename_table(self, old_index_name, index_name)
 
+
+    def _default_value_workaround(self, value):
+        "Support for UUIDs on psql"
+
+        import uuid
+
+        if isinstance(value, uuid.UUID):
+            return str(value)
+        else:
+            return super(DatabaseOperations, self)._default_value_workaround(value)
+
+
     _db_type_for_alter_column = generic.alias("_db_positive_type_for_alter_column")
     _alter_add_column_mods = generic.alias("_alter_add_positive_check")