We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6daf224 commit 8eca533Copy full SHA for 8eca533
1 file changed
backend/src/controllers/problemController.js
@@ -9,7 +9,15 @@ function listProblems(req, res) {
9
10
if (type) { conditions += ' AND type = ?'; params.push(type); }
11
if (difficulty) { conditions += ' AND difficulty = ?'; params.push(difficulty); }
12
- if (search) { conditions += ' AND title LIKE ?'; params.push(`%${search}%`); }
+ if (search) {
13
+ conditions += ' AND (title LIKE ?';
14
+ params.push(`%${search}%`);
15
+ if (/^\d+$/.test(search)) {
16
+ conditions += ' OR id = ?';
17
+ params.push(Number(search));
18
+ }
19
+ conditions += ')';
20
21
22
const total = queryOne(countSql + conditions, params).count;
23
0 commit comments