Ticket #4432: django-4432.diff
File django-4432.diff, 3.3 KB (added by , 17 years ago) |
---|
-
db/backends/postgresql/base.py
221 221 for model in model_list: 222 222 for f in model._meta.fields: 223 223 if isinstance(f, models.AutoField): 224 output.append("%s setval('%s', (%s max(%s) %s %s));" % \224 output.append("%s setval('%s', coalesce(max(%s), 1), max(%s) is not null) %s %s;" % \ 225 225 (style.SQL_KEYWORD('SELECT'), 226 226 style.SQL_FIELD(quote_name('%s_%s_seq' % (model._meta.db_table, f.column))), 227 style.SQL_KEYWORD('SELECT'),228 227 style.SQL_FIELD(quote_name(f.column)), 228 style.SQL_FIELD(quote_name(f.column)), 229 229 style.SQL_KEYWORD('FROM'), 230 230 style.SQL_TABLE(quote_name(model._meta.db_table)))) 231 231 break # Only one AutoField is allowed per model, so don't bother continuing. 232 232 for f in model._meta.many_to_many: 233 output.append("%s setval('%s', (%s max(%s) %s %s));" % \233 output.append("%s setval('%s', coalesce(max(%s), 1), max(%s) is not null) %s %s;" % \ 234 234 (style.SQL_KEYWORD('SELECT'), 235 235 style.SQL_FIELD(quote_name('%s_id_seq' % f.m2m_db_table())), 236 style.SQL_KEYWORD('SELECT'),237 236 style.SQL_FIELD(quote_name('id')), 237 style.SQL_FIELD(quote_name('id')), 238 238 style.SQL_KEYWORD('FROM'), 239 239 style.SQL_TABLE(f.m2m_db_table()))) 240 240 return output -
db/backends/postgresql_psycopg2/base.py
178 178 for model in model_list: 179 179 for f in model._meta.fields: 180 180 if isinstance(f, models.AutoField): 181 output.append("%s setval('%s', (%s max(%s) %s %s));" % \181 output.append("%s setval('%s', coalesce(max(%s), 1), max(%s) is not null) %s %s;" % \ 182 182 (style.SQL_KEYWORD('SELECT'), 183 183 style.SQL_FIELD(quote_name('%s_%s_seq' % (model._meta.db_table, f.column))), 184 style.SQL_KEYWORD('SELECT'),185 184 style.SQL_FIELD(quote_name(f.column)), 185 style.SQL_FIELD(quote_name(f.column)), 186 186 style.SQL_KEYWORD('FROM'), 187 187 style.SQL_TABLE(quote_name(model._meta.db_table)))) 188 188 break # Only one AutoField is allowed per model, so don't bother continuing. 189 189 for f in model._meta.many_to_many: 190 output.append("%s setval('%s', (%s max(%s) %s %s));" % \190 output.append("%s setval('%s', coalesce(max(%s), 1), max(%s) is not null) %s %s;" % \ 191 191 (style.SQL_KEYWORD('SELECT'), 192 192 style.SQL_FIELD(quote_name('%s_id_seq' % f.m2m_db_table())), 193 style.SQL_KEYWORD('SELECT'),194 193 style.SQL_FIELD(quote_name('id')), 194 style.SQL_FIELD(quote_name('id')), 195 195 style.SQL_KEYWORD('FROM'), 196 196 style.SQL_TABLE(f.m2m_db_table()))) 197 197 return output