Adv item search: actually make string comparisons case-insensitive
This commit is contained in:
parent
886d720efe
commit
17af7f8d3f
1 changed files with 14 additions and 4 deletions
18
query_2.js
18
query_2.js
|
@ -344,16 +344,25 @@ class EqualityTerm extends BinaryOpTerm {
|
|||
constructor(left, right) {
|
||||
super('boolean', 'any', left, 'any', right);
|
||||
}
|
||||
|
||||
apply(a, b) {
|
||||
return (typeof a === 'string' && typeof b === 'string')
|
||||
? this.compare(a.toLowerCase(), b.toLowerCase()) : this.compare(a, b);
|
||||
}
|
||||
|
||||
compare(a, b) {
|
||||
throw new Error('Abstract method!');
|
||||
}
|
||||
}
|
||||
|
||||
class EqTerm extends EqualityTerm {
|
||||
apply(a, b) {
|
||||
compare(a, b) {
|
||||
return a === b;
|
||||
}
|
||||
}
|
||||
|
||||
class NeqTerm extends EqualityTerm {
|
||||
apply(a, b) {
|
||||
compare(a, b) {
|
||||
return a !== b;
|
||||
}
|
||||
}
|
||||
|
@ -376,7 +385,8 @@ class InequalityTerm extends BinaryOpTerm {
|
|||
apply(a, b) {
|
||||
checkComparable(a);
|
||||
checkComparable(b);
|
||||
return this.compare(a, b);
|
||||
return (typeof a === 'string' && typeof b === 'string')
|
||||
? this.compare(a.toLowerCase(), b.toLowerCase()) : this.compare(a, b);
|
||||
}
|
||||
|
||||
compare(a, b) {
|
||||
|
@ -434,7 +444,7 @@ class MulTerm extends ArithmeticTerm {
|
|||
|
||||
class DivTerm extends ArithmeticTerm {
|
||||
apply(a, b) {
|
||||
return a / b;
|
||||
return a / b;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue