[chronojump] Sqlite.SelectRunsSA with a separated selectRunsCreateSelection()



commit 7ad02f5884de4e5f8245d1fa49338a0cd96ebaa0
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Jun 18 13:18:01 2020 +0200

    Sqlite.SelectRunsSA with a separated selectRunsCreateSelection()

 src/sqlite/run.cs | 42 ++++++++++++++++++++++++------------------
 1 file changed, 24 insertions(+), 18 deletions(-)
---
diff --git a/src/sqlite/run.cs b/src/sqlite/run.cs
index db8ff4ea..fe3bf42d 100644
--- a/src/sqlite/run.cs
+++ b/src/sqlite/run.cs
@@ -85,50 +85,56 @@ class SqliteRun : Sqlite
 
                return myLast;
        }
-       
-       //like SelectRuns, but this returns a string[] :( better use below method if possible
-       //if all sessions, put -1 in sessionID
-       //if all persons, put -1 in personID
-       //if all types, put "" in filterType
-       //unlimited put -1 in limit
-       //SA for String Array
-       public static string[] SelectRunsSA (bool dbconOpened, int sessionID, int personID, string filterType,
+
+       //note this is selecting also the person.name
+       private static string selectRunsCreateSelection (int sessionID, int personID, string filterType,
                        Orders_by order, int limit) 
        {
-               if(!dbconOpened)
-                       Sqlite.Open();
-
                string tp = Constants.PersonTable;
 
                string filterSessionString = "";
                if(sessionID != -1)
-                       filterSessionString = " AND run.sessionID == " + sessionID;
+                       filterSessionString = " AND run.sessionID = " + sessionID;
 
                string filterPersonString = "";
                if(personID != -1)
-                       filterPersonString = " AND " + tp + ".uniqueID == " + personID;
+                       filterPersonString = " AND " + tp + ".uniqueID = " + personID;
 
                string filterTypeString = "";
                if(filterType != "")
-                       filterTypeString = " AND run.type == \"" + filterType + "\" " ;
+                       filterTypeString = " AND run.type = \"" + filterType + "\" " ;
 
                string orderByString = " ORDER BY upper(" + tp + ".name), run.uniqueID ";
                if(order == Orders_by.ID_DESC)
                        orderByString = " ORDER BY run.uniqueID DESC ";
-               
+
                string limitString = "";
                if(limit != -1)
                        limitString = " LIMIT " + limit;
 
-
-               dbcmd.CommandText = "SELECT " + tp + ".name, run.* " +
+               return "SELECT " + tp + ".name, run.* " +
                        " FROM " + tp + ", run " +
-                       " WHERE " + tp + ".uniqueID == run.personID" + 
+                       " WHERE " + tp + ".uniqueID = run.personID" +
                        filterSessionString +
                        filterPersonString +
                        filterTypeString +
                        orderByString +
                        limitString;
+       }
+
+       //like SelectRuns, but this returns a string[] :( better use below method if possible
+       //if all sessions, put -1 in sessionID
+       //if all persons, put -1 in personID
+       //if all types, put "" in filterType
+       //unlimited put -1 in limit
+       //SA for String Array
+       public static string[] SelectRunsSA (bool dbconOpened, int sessionID, int personID, string filterType,
+                       Orders_by order, int limit)
+       {
+               if(!dbconOpened)
+                       Sqlite.Open();
+
+               dbcmd.CommandText = selectRunsCreateSelection (sessionID, personID, filterType, order, limit);
                
                LogB.SQL(dbcmd.CommandText.ToString());
                dbcmd.ExecuteNonQuery();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]