Fix search by file type

Fixes #966
This commit is contained in:
Dan Stillman 2016-04-25 00:48:38 -04:00
parent 010249e49b
commit a05134e903
2 changed files with 8 additions and 1 deletions

View file

@ -1230,7 +1230,7 @@ Zotero.Search.prototype._buildQuery = Zotero.Promise.coroutine(function* () {
var patterns = yield Zotero.DB.columnQueryAsync(ftSQL, { int: condition.value });
if (patterns) {
for each(str in patterns) {
condSQL += 'mimeType LIKE ? OR ';
condSQL += 'contentType LIKE ? OR ';
condSQLParams.push(str + '%');
}
condSQL = condSQL.substring(0, condSQL.length - 4);

View file

@ -146,6 +146,13 @@ describe("Zotero.Search", function() {
let matches = yield s.search();
assert.deepEqual(matches, [foobarItem.id]);
});
it("should search by attachment file type", function* () {
let s = new Zotero.Search();
s.addCondition('fileTypeID', 'is', Zotero.FileTypes.getID('webpage'));
let matches = yield s.search();
assert.sameMembers(matches, [fooItem.id, foobarItem.id]);
});
});
describe("#toJSON()", function () {