diff mbox series

[10/12] prserv: remove unnecessary code

Message ID 20240412090234.4110915-11-michael.opdenacker@bootlin.com
State Accepted, archived
Commit e4ae5177861c9a27e93e5a2d3a6c393baecd6416
Headers show
Series prserv: add support for an "upstream" server | expand

Commit Message

Michael Opdenacker April 12, 2024, 9:02 a.m. UTC
From: Michael Opdenacker <michael.opdenacker@bootlin.com>

In db.py, the ifnull() statement guarantees that the SQL request will
return a value. It's therefore unnecessary to test the case when no
value is found.

Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
Cc: Joshua Watt <JPEWhacker@gmail.com>
Cc: Tim Orling <ticotimo@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
 lib/prserv/db.py | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
diff mbox series


diff --git a/lib/prserv/db.py b/lib/prserv/db.py
index 7c200602ed..eb41508198 100644
--- a/lib/prserv/db.py
+++ b/lib/prserv/db.py
@@ -172,11 +172,7 @@  class PRTable(object):
             if self.read_only:
                 data = self._execute("SELECT ifnull(max(value)+1, 0) FROM %s where version=? AND pkgarch=?;" % (self.table),
                                    (version, pkgarch))
-                row = data.fetchone()
-                if row is not None:
-                    return row[0]
-                else:
-                    return 0
+                return data.fetchone()[0]
                 self._execute("INSERT OR REPLACE INTO %s VALUES (?, ?, ?, (select ifnull(max(value)+1, 0) from %s where version=? AND pkgarch=?));"