1
0
Fork 0
mirror of https://github.com/veekun/pokedex.git synced 2024-08-20 18:16:34 +00:00

Fixed csvexport to write in primary key order.

Good news: This no longer relies on InnoDB's default row order.

Bad news: InnoDB in MySQL 5.0 has a bug where it will sort rows
physically according to a secondary index, if there's a composite
primary key and a single-column index and the phase of the moon is
right.  So a couple tables have been, once again, reordered -- but
correctly this time.

Good news: This bug will no longer fuck me up!
This commit is contained in:
Eevee 2009-07-26 22:19:27 -07:00
parent cce9c26125
commit 64d3c7d5f1
4 changed files with 1895 additions and 1894 deletions

View file

@ -142,7 +142,8 @@ def command_csvexport(engine_uri, directory='.'):
columns = [col.name for col in table.columns]
writer.writerow(columns)
for row in session.query(table).all():
primary_key = table.primary_key
for row in session.query(table).order_by(*primary_key).all():
csvs = []
for col in columns:
# Convert Pythony values to something more universal