Skip to content

Commit

Permalink
Merge pull request robertohuertasm#30 from pokehanai/feature/aot-indexed
Browse files Browse the repository at this point in the history
Prevent AOT error in iOS, caused by Indexed attr
  • Loading branch information
robertohuertasm committed Nov 23, 2015
2 parents e08069a + 20c8427 commit bf660bc
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions SQLite4Unity3d/SQLite4Unity3d/SQLite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@ static byte[] GetNullTerminatedUtf8 (string s)
/// Used to list some code that we want the MonoTouch linker
/// to see, but that we never want to actually execute.
/// </summary>
#pragma warning disable 649
static bool _preserveDuringLinkMagic;
#pragma warning restore 649

/// <summary>
/// Sets a busy handler to sleep the specified amount of time when a table is locked.
Expand Down Expand Up @@ -447,8 +449,18 @@ public int CreateTable(Type ty, CreateFlags createFlags = CreateFlags.None)

foreach (var indexName in indexes.Keys) {
var index = indexes[indexName];
var columns = index.Columns.OrderBy(i => i.Order).Select(i => i.ColumnName).ToArray();
count += CreateIndex(indexName, index.TableName, columns, index.Unique);
string[] columnNames = new string[index.Columns.Count];
if (index.Columns.Count == 1) {
columnNames[0] = index.Columns[0].ColumnName;
} else {
index.Columns.Sort((lhs, rhs) => {
return lhs.Order - rhs.Order;
});
for (int i = 0, end = index.Columns.Count; i < end; ++i) {
columnNames[i] = index.Columns[i].ColumnName;
}
}
count += CreateIndex(indexName, index.TableName, columnNames, index.Unique);
}

return count;
Expand Down

0 comments on commit bf660bc

Please sign in to comment.