bool done;
done = true;
int64 rowID;
+ // Because we use GoToSysID() and the sysIDStatement when searching for a primary key with Find(),
+ // this flag is used to distinguish between a Find() and a GoToSysID() for Select(next) purposes:
+ bool findSysID;
bool Nil()
{
case middle:
break;
case next:
- if(!stepping)
+ // For sysID statement, for a Find() we want to go through next/previous in order, otherwise we just go to nil
+ if(!stepping && (curStatement != sysIDStatement || findSysID))
{
result = sqlite3_step(curStatement);
done = result == SQLITE_DONE || (result && result != SQLITE_ROW);
if(fld == tbl.primaryKey)
{
- return GoToSysID(*(int *)data);
+ result = GoToSysID(*(int *)data);
+ if(result)
+ findSysID = true;
+ return result;
}
sprintf(command, "SELECT ROWID, * FROM `%s` WHERE ", tbl.name);
}
sqlite3_reset(id ? insertIDStatement : insertStatement);
curStatement = sysIDStatement;
+ findSysID = false;
sqlite3_reset(curStatement);
sqlite3_bind_int64(sysIDStatement, 1, (sqlite3_int64)rowID);
result = sqlite3_step(curStatement);
//sprintf(command, "SELECT ROWID, * FROM `%s` WHERE ROWID = ?;", tbl.name);
//result = sqlite3_prepare_v2(tbl.db.db, command, -1, &statement, null);
+ findSysID = false;
if(curStatement)
sqlite3_reset(curStatement);
{
bool result;
DebugLn("TableEditor::Select");
- if(idField && editRow.Find(idField, middle, nil, id))
+ // EDA is now set up so that Next()/Prev() will work with sysID = , but not with Find() (As Find() will return a particular set of results)
+ if(idField && (editRow.sysID = id, !editRow.nil))// && editRow.Find(idField, middle, nil, id))
{
//Id test = editRow.sysID;
selectedId = editRow.sysID;