Commits

Andrew Godwin committed eb5a5f8

Fixing #383 and #377 (sqlite regen errors)

Comments (0)

Files changed (2)

south/db/generic.py

             ))
 
 
-    def column_sql(self, table_name, field_name, field, tablespace=''):
+    def column_sql(self, table_name, field_name, field, tablespace='', with_name=True, field_prepared=False):
         """
         Creates the SQL snippet for a column. Used by add_column and add_table.
         """
 
-        field.set_attributes_from_name(field_name)
+        # If the field hasn't already been told its attribute name, do so.
+        if not field_prepared:
+            field.set_attributes_from_name(field_name)
 
         # hook for the field to do any resolution prior to it's attributes being queried
         if hasattr(field, 'south_init'):
         except TypeError:
             sql = field.db_type()
         
-        if sql:        
-            field_output = [self.quote_name(field.column), sql]
+        if sql:
+            
+            # Some callers, like the sqlite stuff, just want the extended type.
+            if with_name:
+                field_output = [self.quote_name(field.column), sql]
+            else:
+                field_output = [sql]
+            
             field_output.append('%sNULL' % (not field.null and 'NOT ' or ''))
             if field.primary_key:
                 field_output.append('PRIMARY KEY')

south/db/sqlite3.py

         # Get the column's SQL
         field.set_attributes_from_name(name)
         if not explicit_name:
-            name = field.column
+            name = field.db_column
         else:
             field.column = name
-        sql = self.column_sql(table_name, name, field)
+        sql = self.column_sql(table_name, name, field, with_name=False, field_prepared=True)
         # Remake the table correctly
         self._remake_table(table_name, altered={name: sql})
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.