mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
fix searching multi-valued attributes, closes #800
This commit is contained in:
parent
51dddb0bbb
commit
232321f3a4
@ -21,17 +21,19 @@ module.exports = function(filters, selectedColumns = 'notes.*') {
|
||||
"notes": null
|
||||
};
|
||||
|
||||
let attrFilterId = 1;
|
||||
|
||||
function getAccessor(property) {
|
||||
let accessor;
|
||||
|
||||
if (!VIRTUAL_ATTRIBUTES.includes(property)) {
|
||||
const alias = "attr_" + property;
|
||||
// not reusing existing filters to support multi-valued filters e.g. "@tag=christmas @tag=shopping"
|
||||
// can match notes because @tag can be both "shopping" and "christmas"
|
||||
const alias = "attr_" + property + "_" + attrFilterId++;
|
||||
|
||||
if (!(alias in joins)) {
|
||||
joins[alias] = `LEFT JOIN attributes AS ${alias} `
|
||||
+ `ON ${alias}.noteId = notes.noteId `
|
||||
+ `AND ${alias}.name = '${property}' AND ${alias}.isDeleted = 0`;
|
||||
}
|
||||
joins[alias] = `LEFT JOIN attributes AS ${alias} `
|
||||
+ `ON ${alias}.noteId = notes.noteId `
|
||||
+ `AND ${alias}.name = '${property}' AND ${alias}.isDeleted = 0`;
|
||||
|
||||
accessor = `${alias}.value`;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user