eda/drivers/SQLite: Printing query errors
[sdk] / eda / drivers / sqlite / EDASQLite.ec
index b845bca..68d3ab2 100644 (file)
@@ -185,6 +185,8 @@ class SQLiteDatabase : Database
    ~SQLiteDatabase()
    {
       sqlite3_exec(db, "PRAGMA locking_mode=normal", null, null, null);
+      // "Simply setting the locking-mode to NORMAL is not enough - locks are not released until the next time the database file is accessed."
+      sqlite3_exec(db, "SELECT COUNT(*) from eda_table_fields", null, null, null);
       sqlite3_close(db);
    }
 
@@ -337,7 +339,7 @@ class SQLiteDatabase : Database
                      Class type = null;
                      int sqliteType = SQLITE_BLOB;
 
-                     ((Class)(&type)).OnGetDataFromString(typeName);    // TODO: THIS REQUIRES A FIX SOMEWHERE ELSE
+                     type.OnGetDataFromString(typeName);
 
                      if(type)
                      {
@@ -364,7 +366,7 @@ class SQLiteDatabase : Database
                      }
 
                      {
-                        Table * fTable = (Table *)eClass_GetProperty(type, "table");
+                        Table * fTable = (Table *)(intptr)eClass_GetProperty(type, "table");
                         SQLiteField field { tbl = table, name = CopyString(fieldName), type = type, length = length, num = table._fields.count, sqliteType = sqliteType };
                         incref field;
                         if(fTable) refTable = *fTable;
@@ -836,7 +838,7 @@ class SQLiteTable : Table
       }
       if(sqliteType != SQLITE_BLOB && eClass_IsDerived(type, class(eda::Id)))
       {
-         Table * table = (Table *)eClass_GetProperty(type, "table");
+         Table * table = (Table *)(intptr)eClass_GetProperty(type, "table");
          if(table) refTable = *table;
          if(refTable)
          {
@@ -925,7 +927,7 @@ class SQLiteTable : Table
             if(f.sqliteType != SQLITE_BLOB && eClass_IsDerived(f.type, class(eda::Id)))
             {
 
-               Table * tablePtr = (Table *)eClass_GetProperty(f.type, "table");
+               Table * tablePtr = (Table *)(intptr)eClass_GetProperty(f.type, "table");
                if(tablePtr && *tablePtr == this)
                   primaryKey = f;
             }
@@ -1292,7 +1294,10 @@ class SQLiteRow : DriverRow
             }
          }
          else
+         {
+            printf("SQLite Query Error: %s\n", queryString);
             status = false;
+         }
       }
       else
          curStatement = null;
@@ -1442,13 +1447,13 @@ class SQLiteRow : DriverRow
                }
                if(type.type == structClass)
                {
-                  data = (int64)new0 byte[type.structSize];
-                  dataPtr = (void *) data;
+                  data = (int64)(intptr)new0 byte[type.structSize];
+                  dataPtr = (void *)(intptr)data;
                }
                // ((bool (*)())(void *)dataRow.GetData)(dataRow, fld, type, (type.type == structClass) ? (void *)data : &data);
-               ((bool (*)())(void *)this.GetData)(this, fld, type, (type.type == structClass) ? (void *)data : &data);
+               ((bool (*)())(void *)this.GetData)(this, fld, type, (type.type == structClass) ? (void *)(intptr)data : &data);
                if(type.type == normalClass || type.type == noHeadClass)
-                  dataPtr = (void *) data;
+                  dataPtr = (void *)(intptr)data;
                else
                   dataPtr = &data;
                ((bool (*)())(void *)this.BindData)(this, stmt, (*bindId)++, fld, type, dataPtr, &buffer);