catalog-react: support string=number comparisons for entity predicates
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -109,6 +109,8 @@ describe('entityPredicateToFilterFunction', () => {
|
||||
owner: 'g',
|
||||
definition: 'mock',
|
||||
nothing: null,
|
||||
oneNum: 1,
|
||||
oneStr: '1',
|
||||
},
|
||||
relations: [
|
||||
{
|
||||
@@ -219,6 +221,10 @@ describe('entityPredicateToFilterFunction', () => {
|
||||
['', { 'spec.nothing': null }],
|
||||
['w,g,a', { $not: { 'spec.type': 'service' } }],
|
||||
['', { 'spec.type': null }],
|
||||
['a', { 'spec.oneNum': 1 }],
|
||||
['a', { 'spec.oneStr': 1 }],
|
||||
['a', { 'spec.oneNum': '1' }],
|
||||
['a', { 'spec.oneStr': '1' }],
|
||||
[
|
||||
's,w',
|
||||
{
|
||||
|
||||
@@ -117,6 +117,9 @@ function valuesAreEqual(
|
||||
if (typeof a === 'string' && typeof b === 'string') {
|
||||
return a.toLocaleUpperCase('en-US') === b.toLocaleUpperCase('en-US');
|
||||
}
|
||||
if (typeof a === 'number' || typeof b === 'number') {
|
||||
return String(a) === String(b);
|
||||
}
|
||||
if (Array.isArray(a) && Array.isArray(b)) {
|
||||
return a.length === b.length && a.every((v, i) => valuesAreEqual(v, b[i]));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user