def get_sql_sequence_reset(app):
    "Returns a list of the SQL statements to reset PostgreSQL sequences for the given app."
    from django.db import backend, models
    output = []
    for model in models.get_models(app):
        for f in model._meta.fields:
            if isinstance(f, models.AutoField):
                output.append("%s setval('%s', (%s max(%s) %s %s));" % \
                    (style.SQL_KEYWORD('SELECT'),
                    style.SQL_FIELD((model._meta.db_table, f.column) % '%s_%s_seq'),
                    style.SQL_KEYWORD('SELECT'),
                    style.SQL_FIELD(backend.quote_name(f.column)),
                    style.SQL_KEYWORD('FROM'),
                    style.SQL_TABLE(backend.quote_name(model._meta.db_table))))
                break # Only one AutoField is allowed per model, so don't bother continuing.
        for f in model._meta.many_to_many:
            output.append("%s setval('%s', (%s max(%s) %s %s));" % \
                (style.SQL_KEYWORD('SELECT'),
                style.SQL_FIELD('%s_id_seq' % f.m2m_db_table()),
                style.SQL_KEYWORD('SELECT'),
                style.SQL_FIELD(backend.quote_name('id')),
                style.SQL_KEYWORD('FROM'),
                style.SQL_TABLE(f.m2m_db_table())))
    return output
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-0.96/django/core/management.py/get_sql_sequence_reset/swapped operands of `%`