jgilfelt/android-sqlite-asset-helper — pull request #21 by jon-adams (2013-10-25 23:07:29+00:00)
Title: Fix incorrect alphanumeric sorting of upgrade scripts that can cause them to be applied in the wrong order

This patch fixes the case when applying many upgrade scripts at once that go up to the next digit, for example from 9 to 10, or 99 to 100, from being applied in the wrong order.

The patch upgrades the Sort call on the file list to compare paths by their upgrade version numbers, instead of using alphanumeric comparison on plain file names.

For example, when applying 2 different upgrade files from version 9 to 11, this fix keeps it from using the incorrect alphanumeric order of 10_11 before 9_10, and instead runs them in the correct order of 9_10 then 10_11.

I thought about changing some of the logic order so that it can do this compare earlier without the regular expression parsing, but that would be a fairly decent logic adjustment. So I opted for keeping this code separated out into its own class (but still nested in the main class).