fix the sqlite3_bind() for query-by-name, the wildcards '%'
authorKlaus Kaempf <kkaempf@suse.de>
Thu, 16 Aug 2007 20:31:41 +0000 (20:31 +0000)
committerKlaus Kaempf <kkaempf@suse.de>
Thu, 16 Aug 2007 20:31:41 +0000 (20:31 +0000)
 must be part of the value, not the sql statement
 see http://archives.devshed.com/forums/databases-124/problem-when-binding-with-like-1077713.html

zypp/cache/ResolvableQuery.cc

index af27cb8..dbf509e 100644 (file)
@@ -89,8 +89,8 @@ struct ResolvableQuery::Impl
     sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
     //con.executenonquery("PRAGMA cache_size=8000;");
     con.executenonquery("BEGIN;");
-    sqlite3_command cmd( con, "select " + _fields + " from resolvables where name like '%:name%';");
-    cmd.bind(":name", s);
+    sqlite3_command cmd( con, "select " + _fields + " from resolvables where name like :name;");
+    cmd.bind(":name", string("%") + s + "%");
     sqlite3_reader reader = cmd.executereader();
     while(reader.read())
     {