Kaynağa Gözat

Revert "Fix DB query to fetch owned files"

This reverts commit a6b8d229ddd8e22e058dde176ad33502a00997b6.
Vishnu Mohandas 4 yıl önce
ebeveyn
işleme
fb897e9264
1 değiştirilmiş dosya ile 13 ekleme ve 4 silme
  1. 13 4
      lib/db/files_db.dart

+ 13 - 4
lib/db/files_db.dart

@@ -117,16 +117,25 @@ class FilesDB {
     final db = await instance.database;
     final db = await instance.database;
     final results = await db.query(table,
     final results = await db.query(table,
         where: '$columnGeneratedID = ?', whereArgs: [generatedID]);
         where: '$columnGeneratedID = ?', whereArgs: [generatedID]);
-    return _convertToFiles(results)[0];
+    final convertedResults = _convertToFiles(results);
+    if (convertedResults.length == 0) {
+      return null;
+    } else {
+      return convertedResults[1];
+    }
   }
   }
 
 
   Future<List<File>> getOwnedFiles(int ownerID) async {
   Future<List<File>> getOwnedFiles(int ownerID) async {
     final db = await instance.database;
     final db = await instance.database;
+    final whereArgs = List<dynamic>();
+    if (ownerID != null) {
+      whereArgs.add(ownerID);
+    }
     final results = await db.query(
     final results = await db.query(
       table,
       table,
-      where: '$columnIsDeleted = 0' +
-          (ownerID == null ? '' : ' AND $columnOwnerID = ?'),
-      whereArgs: [ownerID],
+      // where: '$columnIsDeleted = 0' +
+      //     (ownerID == null ? '' : ' AND $columnOwnerID = ?'),
+      // whereArgs: whereArgs,
       orderBy: '$columnCreationTime DESC',
       orderBy: '$columnCreationTime DESC',
     );
     );
     return _convertToFiles(results);
     return _convertToFiles(results);