Ticket #2257: 2257_fullname_1.patch
File 2257_fullname_1.patch, 1.2 KB (added by , 18 years ago) |
---|
-
management.py
192 192 data_types = get_creation_module().DATA_TYPES 193 193 194 194 final_output = [] 195 reference_names = {}196 195 if backend.supports_constraints: 197 196 opts = model._meta 198 197 if model in pending_references: … … 202 201 r_col = f.column 203 202 table = opts.db_table 204 203 col = opts.get_field(f.rel.field_name).column 205 r_name = '%s_referencing_%s_%s' % (r_col, table, col) 206 if r_name in reference_names: 207 reference_names[r_name] += 1 208 r_name += '_%s' % reference_names[r_name] 209 else: 210 reference_names[r_name] = 0 204 r_name = '%s_%s_references_%s_%s' % (r_table, r_col, table, col) 211 205 final_output.append(style.SQL_KEYWORD('ALTER TABLE') + ' %s ADD CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s);' % \ 212 206 (backend.quote_name(r_table), r_name, 213 207 backend.quote_name(r_col), backend.quote_name(table), backend.quote_name(col)))