summaryrefslogtreecommitdiff
path: root/portato/db/sql.py
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2010-03-05 01:51:35 +0100
committerRené 'Necoro' Neumann <necoro@necoro.net>2010-03-05 01:51:35 +0100
commitbb95009b602311c280b4649aa6615099ceca11c0 (patch)
tree593bd7ae35fcae7114346c1dac09a1ac41a51ec0 /portato/db/sql.py
parent49a7533e65d6f6904d76ec417dc1611514d5e57a (diff)
downloadportato-bb95009b602311c280b4649aa6615099ceca11c0.tar.gz
portato-bb95009b602311c280b4649aa6615099ceca11c0.tar.bz2
portato-bb95009b602311c280b4649aa6615099ceca11c0.zip
Add description support to the databases
Diffstat (limited to 'portato/db/sql.py')
-rw-r--r--portato/db/sql.py26
1 files changed, 20 insertions, 6 deletions
diff --git a/portato/db/sql.py b/portato/db/sql.py
index fbc01e6..48de9eb 100644
--- a/portato/db/sql.py
+++ b/portato/db/sql.py
@@ -34,7 +34,7 @@ from .database import Database, PkgData
class SQLDatabase (Database):
- FORMAT = "1"
+ FORMAT = "2"
FORBIDDEN = (".bzr", ".svn", ".git", "CVS", ".hg", "_darcs")
lock = Database.lock
@@ -68,6 +68,7 @@ class SQLDatabase (Database):
(
name TEXT,
cat TEXT,
+ descr TEXT DEFAULT "",
inst INTEGER,
disabled INTEGER
)""")
@@ -83,6 +84,9 @@ class SQLDatabase (Database):
pkg_conn.close()
+ def search_types(self):
+ return Database.SEARCH_NAME
+
def updated (self):
changed = False
@@ -253,12 +257,22 @@ class SQLDatabase (Database):
self._restrict = ""
else:
restrict = restrict.replace(".*","%").replace(".","_")
+ rest = ""
+
+ if self._type & Database.NAME_DESCRIPTION:
+ if "/" in restrict:
+ rest = "(name LIKE '%s%%' AND cat LIKE '%s')" % (pkg, cat)
+ else:
+ rest = "(name LIKE '%%%(restrict)s%%' OR cat LIKE '%(restrict)s%%')" % {"restrict":restrict}
- if "/" in restrict:
- cat,pkg = restrict.split("/")
- self._restrict = "AND name LIKE '%s%%' AND cat LIKE '%s'" % (pkg, cat)
- else:
- self._restrict = "AND (name LIKE '%%%(restrict)s%%' OR cat LIKE '%(restrict)s%%')" % {"restrict":restrict}
+ if self._type & Database.SEARCH_DESCRIPTION:
+ r = "descr LIKE '%%%(restrict)s%%'" % {"restrict":restrict}
+ if not rest:
+ rest = "(%s OR %s)" % (r, rest)
+ else:
+ rest = r
+
+ self._restrict = "AND " + rest
restrict = property(get_restrict, set_restrict)
con = staticmethod(con)