diff mbox series

[v2,11/12] prserv: remove unnecessary code

Message ID 20240405164125.1652579-12-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 5, 2024, 4:41 p.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

Patch

diff --git a/lib/prserv/db.py b/lib/prserv/db.py
index 3b0713def6..7aad6a1576 100644
--- a/lib/prserv/db.py
+++ b/lib/prserv/db.py
@@ -124,11 +124,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]
 
             try:
                 self._execute("INSERT OR REPLACE INTO %s VALUES (?, ?, ?, (select ifnull(max(value)+1, 0) from %s where version=? AND pkgarch=?));"