Post by mythrix on Dec 4, 2021 19:17:19 GMT
****EDIT: workaround found, but leaving this here in case it helps either Dev or others. Workaround at the bottom.
Hi,
Can I first of all say what a fantastic asset you've created. It has the world of difference to my project.
It has been working very well for me for a couple of years but I recently decided to add another table for my players and unfortunately it's crashing the game and I just can't get to the bottom of the error.
The Unity crash log says this:
SQLiteException: no such table: LeagueHistory
SimpleSQL.SQLite3.Prepare2 (System.IntPtr db, System.String query) (at <468c3ab363e542f69ac6146c520208f3>:0)
SimpleSQL.SQLiteCommand.Prepare () (at <468c3ab363e542f69ac6146c520208f3>:0)
SimpleSQL.SQLiteCommand.ExecuteNonQuery () (at <468c3ab363e542f69ac6146c520208f3>:0)
SimpleSQL.SQLiteConnection.Execute (System.String query, System.Object[] args) (at <468c3ab363e542f69ac6146c520208f3>:0)
SimpleSQL.SQLiteConnection.MigrateTable (SimpleSQL.TableMapping map) (at <468c3ab363e542f69ac6146c520208f3>:0)
SimpleSQL.SQLiteConnection.CreateTable[T] () (at <468c3ab363e542f69ac6146c520208f3>:0)
SimpleSQL.SimpleSQLManager.CreateTable[T] () (at <468c3ab363e542f69ac6146c520208f3>:0)
DataManager.Awake () (at Assets/Scripts/DataManager.cs:107)
SimpleSQL.SQLite3.Prepare2 (System.IntPtr db, System.String query) (at <468c3ab363e542f69ac6146c520208f3>:0)
SimpleSQL.SQLiteCommand.Prepare () (at <468c3ab363e542f69ac6146c520208f3>:0)
SimpleSQL.SQLiteCommand.ExecuteNonQuery () (at <468c3ab363e542f69ac6146c520208f3>:0)
SimpleSQL.SQLiteConnection.Execute (System.String query, System.Object[] args) (at <468c3ab363e542f69ac6146c520208f3>:0)
SimpleSQL.SQLiteConnection.MigrateTable (SimpleSQL.TableMapping map) (at <468c3ab363e542f69ac6146c520208f3>:0)
SimpleSQL.SQLiteConnection.CreateTable[T] () (at <468c3ab363e542f69ac6146c520208f3>:0)
SimpleSQL.SimpleSQLManager.CreateTable[T] () (at <468c3ab363e542f69ac6146c520208f3>:0)
DataManager.Awake () (at Assets/Scripts/DataManager.cs:107)
The DataManager line 107 is just this:
dbManager.CreateTable<LeagueHistory>();
My 'LeagueHistory' class is as follows, and contains no defaults as per your FAQ possible solution for this bug:
public class LeagueHistory
{
[PrimaryKey]
public int LHID { get; set; }
public int League { get; set; }
public int Season { get; set; }
public int Points { get; set; }
public int Wins { get; set; }
public int Losses { get; set; }
public int Kills { get; set; }
public int For { get; set; }
public int Against { get; set; }
public int SpareInt { get; set; }
public string SpareString { get; set; }
public string WinTeam { get; set; }
public bool SpareBool { get; set; }
}
{
[PrimaryKey]
public int LHID { get; set; }
public int League { get; set; }
public int Season { get; set; }
public int Points { get; set; }
public int Wins { get; set; }
public int Losses { get; set; }
public int Kills { get; set; }
public int For { get; set; }
public int Against { get; set; }
public int SpareInt { get; set; }
public string SpareString { get; set; }
public string WinTeam { get; set; }
public bool SpareBool { get; set; }
}
Can you see what the problem is?
Many thanks for your time!
******EDIT: Workaround:
I remembered that in your manual you actually had two different ways of creating a new table. I used the other manual version:
string sql;
sql = "CREATE TABLE \"LeagueHistoryNew\" " +
"(\"LHID\" INTEGER PRIMARY KEY NOT NULL, " +
"\"League\" INTEGER, " +
"\"Season\" INTEGER, " +
"\"Points\" INTEGER, " +
"\"Wins\" INTEGER, " +
"\"Losses\" INTEGER, " +
"\"Kills\" INTEGER, " +
"\"For\" INTEGER, " +
"\"Against\" INTEGER, " +
"\"SpareInt\" INTEGER, " +
"\"SpareString\" TEXT, " +
"\"WinTeam\" TEXT, " +
"\"SpareBool\" BOOLEAN)";
dbManager.Execute(sql);
sql = "CREATE TABLE \"LeagueHistoryNew\" " +
"(\"LHID\" INTEGER PRIMARY KEY NOT NULL, " +
"\"League\" INTEGER, " +
"\"Season\" INTEGER, " +
"\"Points\" INTEGER, " +
"\"Wins\" INTEGER, " +
"\"Losses\" INTEGER, " +
"\"Kills\" INTEGER, " +
"\"For\" INTEGER, " +
"\"Against\" INTEGER, " +
"\"SpareInt\" INTEGER, " +
"\"SpareString\" TEXT, " +
"\"WinTeam\" TEXT, " +
"\"SpareBool\" BOOLEAN)";
dbManager.Execute(sql);
It now works fine, but this is a little less elegant. Hopefully that helps identify where the bug/error/user error was in the first place.