]> mj.ucw.cz Git - pciids.git/commitdiff
Search sorts by ID length primarily
authorMichal Vaner <vorner@ucw.cz>
Sat, 4 Oct 2008 18:34:39 +0000 (20:34 +0200)
committerMichal Vaner <vorner@ucw.cz>
Sat, 4 Oct 2008 18:34:39 +0000 (20:34 +0200)
PciIds/DBQ.pm

index d3893695b212def42bcb745fdf09631418e4f896..0446fb43433ad3803290a31f0681b8717ff4a241 100644 (file)
@@ -113,8 +113,8 @@ sub new( $ ) {
                'dropnotifsxmpp' => 'DELETE FROM pending WHERE notification = 1 AND EXISTS ( SELECT 1 FROM users WHERE users.id = pending.user AND nextxmpp <= ? )',
                'dropnotifsmail' => 'DELETE FROM pending WHERE notification = 0 AND EXISTS ( SELECT 1 FROM users WHERE users.id = pending.user AND nextmail <= ? )',
                'time' => 'SELECT NOW()',
-               'searchname' => 'SELECT l.id, l.name, p.name FROM locations AS l JOIN locations AS p ON l.parent = p.id WHERE l.name LIKE ? ORDER BY l.id',
-               'searchlocalname' => 'SELECT l.id, l.name, p.name FROM locations AS l JOIN locations AS p ON l.parent = p.id WHERE l.name LIKE ? AND l.id LIKE ? ORDER BY l.id',
+               'searchname' => 'SELECT l.id, l.name, p.name FROM locations AS l JOIN locations AS p ON l.parent = p.id WHERE l.name LIKE ? ORDER BY LENGTH(l.id), l.id',
+               'searchlocalname' => 'SELECT l.id, l.name, p.name FROM locations AS l JOIN locations AS p ON l.parent = p.id WHERE l.name LIKE ? AND l.id LIKE ? ORDER BY LENGTH(l.id), l.id',
                'hasChildren' => 'SELECT DISTINCT 1 FROM locations WHERE parent = ?',
                'hasMain' => 'SELECT DISTINCT 1 FROM locations WHERE id = ? AND mainhistory IS NOT NULL',
                'notif-exists' => 'SELECT DISTINCT 1 FROM notifications WHERE user = ? AND ( location = ? OR ( recursive = 1 AND type <= 1 AND SUBSTR( ?, 1, LENGTH( location ) ) = location ) )'