Skip to content

Commit ef33d9c

Browse files
committed
Fix the query for subcategories to only include the next level
And not all descendant categories
1 parent f0733d5 commit ef33d9c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/category.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ impl Category {
147147
pub fn subcategories(&self, conn: &GenericConnection)
148148
-> CargoResult<Vec<Category>> {
149149
let stmt = try!(conn.prepare("SELECT * FROM categories \
150-
WHERE category ILIKE $1 || '::%'"));
150+
WHERE category ILIKE $1 || '::%'
151+
AND category NOT ILIKE $1 || '::%::%'"));
151152
let rows = try!(stmt.query(&[&self.category]));
152153
Ok(rows.iter().map(|r| Model::from_row(&r)).collect())
153154
}

0 commit comments

Comments
 (0)