Ticket #5055: postgresql.diff
File postgresql.diff, 3.4 KB (added by , 17 years ago) |
---|
-
db/backends/postgresql/base.py
189 189 column_name = sequence_info['column'] 190 190 if column_name and len(column_name)>0: 191 191 # sequence name in this case will be <table>_<column>_seq 192 sql.append("%s %s %s %s %s %s;" % \ 193 (style.SQL_KEYWORD('ALTER'), 194 style.SQL_KEYWORD('SEQUENCE'), 195 style.SQL_FIELD('%s_%s_seq' % (table_name, column_name)), 196 style.SQL_KEYWORD('RESTART'), 197 style.SQL_KEYWORD('WITH'), 198 style.SQL_FIELD('1') 199 ) 192 sql.append("%s setval('%s', 1, false);" % \ 193 (style.SQL_KEYWORD('SELECT'), 194 style.SQL_FIELD(quote_name('%s_%s_seq' % (table_name, column_name))) 195 ) 200 196 ) 201 197 else: 202 198 # sequence name in this case will be <table>_id_seq 203 sql.append("%s %s %s %s %s %s;" % \ 204 (style.SQL_KEYWORD('ALTER'), 205 style.SQL_KEYWORD('SEQUENCE'), 206 style.SQL_FIELD('%s_id_seq' % table_name), 207 style.SQL_KEYWORD('RESTART'), 208 style.SQL_KEYWORD('WITH'), 209 style.SQL_FIELD('1') 199 sql.append("%s setval('%s', 1, false);" % \ 200 (style.SQL_KEYWORD('SELECT'), 201 style.SQL_FIELD(quote_name('%s_id_seq' % table_name)) 210 202 ) 211 203 ) 212 204 return sql -
db/backends/postgresql_psycopg2/base.py
146 146 column_name = sequence['column'] 147 147 if column_name and len(column_name) > 0: 148 148 # sequence name in this case will be <table>_<column>_seq 149 sql.append("%s %s %s %s %s %s;" % \ 150 (style.SQL_KEYWORD('ALTER'), 151 style.SQL_KEYWORD('SEQUENCE'), 152 style.SQL_FIELD('%s_%s_seq' % (table_name, column_name)), 153 style.SQL_KEYWORD('RESTART'), 154 style.SQL_KEYWORD('WITH'), 155 style.SQL_FIELD('1') 149 sql.append("%s setval('%s', 1, false);" % \ 150 (style.SQL_KEYWORD('SELECT'), 151 style.SQL_FIELD(quote_name('%s_%s_seq' % (table_name, column_name))) 156 152 ) 157 153 ) 158 154 else: 159 155 # sequence name in this case will be <table>_id_seq 160 sql.append("%s %s %s %s %s %s;" % \ 161 (style.SQL_KEYWORD('ALTER'), 162 style.SQL_KEYWORD('SEQUENCE'), 163 style.SQL_FIELD('%s_id_seq' % table_name), 164 style.SQL_KEYWORD('RESTART'), 165 style.SQL_KEYWORD('WITH'), 166 style.SQL_FIELD('1') 156 sql.append("%s setval('%s', 1, false);" % \ 157 (style.SQL_KEYWORD('SELECT'), 158 style.SQL_FIELD(quote_name('%s_id_seq' % table_name)) 167 159 ) 168 160 ) 169 161 return sql