[chronojump] SelectCurrentSessionPersons and ...AsList can work with sessionID = -1
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] SelectCurrentSessionPersons and ...AsList can work with sessionID = -1
- Date: Wed, 6 Oct 2021 14:25:59 +0000 (UTC)
commit 8197f99eeefba13ac726fcf21db85bc50a6d2f83
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Oct 6 16:24:25 2021 +0200
SelectCurrentSessionPersons and ...AsList can work with sessionID = -1
src/sqlite/personSession.cs | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/src/sqlite/personSession.cs b/src/sqlite/personSession.cs
index 12174b50d..4c0b4c8a4 100644
--- a/src/sqlite/personSession.cs
+++ b/src/sqlite/personSession.cs
@@ -259,21 +259,23 @@ class SqlitePersonSession : Sqlite
}
//sessionID can be -1
- //TODO: add the sessionID -1 code
public static List<Person> SelectCurrentSessionPersonsAsList (bool dbconOpened, int sessionID)
{
+ if(! dbconOpened)
+ Sqlite.Open();
+
string tp = Constants.PersonTable;
string tps = Constants.PersonSessionTable;
-
string tpsString = "";
- if(! dbconOpened)
- Sqlite.Open();
+ string sessionIDString = tps + ".sessionID = " + sessionID + " AND ";
+ if(sessionID == -1)
+ sessionIDString = "";
dbcmd.CommandText = "SELECT " + tp + ".*" +
" FROM " + tp + ", " + tps +
- " WHERE " + tps + ".sessionID == " + sessionID +
- " AND " + tp + ".uniqueID == " + tps + ".personID " +
+ " WHERE " + sessionIDString +
+ tp + ".uniqueID = " + tps + ".personID " +
" ORDER BY upper(" + tp + ".name)";
LogB.SQL(dbcmd.CommandText.ToString());
dbcmd.ExecuteNonQuery();
@@ -308,7 +310,7 @@ class SqlitePersonSession : Sqlite
}
//the difference between this select and others, is that this returns and ArrayList of Persons
//this is better than return the strings that can produce bugs in the future
- //use this in the future:
+ //sessionID can be -1
public static ArrayList SelectCurrentSessionPersons(int sessionID, bool returnPersonAndPSlist)
{
string tp = Constants.PersonTable;
@@ -317,12 +319,16 @@ class SqlitePersonSession : Sqlite
string tpsString = "";
if(returnPersonAndPSlist)
tpsString = ", " + tps + ".* ";
+
+ string sessionIDString = tps + ".sessionID = " + sessionID + " AND ";
+ if(sessionID == -1)
+ sessionIDString = "";
Sqlite.Open();
dbcmd.CommandText = "SELECT " + tp + ".*" + tpsString +
" FROM " + tp + ", " + tps +
- " WHERE " + tps + ".sessionID == " + sessionID +
- " AND " + tp + ".uniqueID == " + tps + ".personID " +
+ " WHERE " + sessionIDString +
+ tp + ".uniqueID = " + tps + ".personID " +
" ORDER BY upper(" + tp + ".name)";
LogB.SQL(dbcmd.CommandText.ToString());
dbcmd.ExecuteNonQuery();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]