Fix the index creation failure

This commit is contained in:
Namhyeon Go 2025-06-23 18:15:37 +09:00
parent ece369f8f0
commit 3e4b6a73b5
2 changed files with 18 additions and 7 deletions

View File

@ -105,22 +105,23 @@ namespace WelsonJS.Launcher
Api.JetAddColumn(_session, tableid, col.Name, coldef, null, 0, out _);
}
string indexKey = $"+{_primaryKey.Name}\0";
int keyLength = Encoding.ASCII.GetByteCount(indexKey + "\0"); // double null-terminated
string fullKeyDescription = indexKey + "\0";
string indexName = "primary";
string key = $"+{_primaryKey.Name}\0";
string keyDescription = key + "\0"; // double null-terminated
int keyDescriptionLength = Encoding.ASCII.GetByteCount(keyDescription); // in characters
Api.JetCreateIndex(
_session,
tableid,
"primary",
indexName,
CreateIndexGrbit.IndexPrimary | CreateIndexGrbit.IndexUnique,
fullKeyDescription,
keyLength,
keyDescription,
keyDescriptionLength,
100
);
Api.JetCommitTransaction(_session, CommitTransactionGrbit.None);
Api.JetCloseTable(_session, tableid);
Api.JetCommitTransaction(_session, CommitTransactionGrbit.None);
}
private void CacheColumns()

View File

@ -17,6 +17,16 @@ namespace WelsonJS.Launcher.Storage
public JET_CP CodePage { get; set; }
public bool IsPrimaryKey { get; set; } = false;
public override string ToString()
{
return Name;
}
public static explicit operator string(Column c)
{
return c.ToString();
}
public Column(string name, JET_coltyp type, int maxSize = 0, JET_CP codePage = JET_CP.None)
{
Name = name;