diff --git a/packages/devextreme/js/core/utils/data.js b/packages/devextreme/js/core/utils/data.js index 6ba42466912e..bdab197f475e 100644 --- a/packages/devextreme/js/core/utils/data.js +++ b/packages/devextreme/js/core/utils/data.js @@ -190,7 +190,8 @@ export const toComparable = function(value, caseSensitive, options = {}) { return value.valueOf(); } - if(!caseSensitive && typeof value === 'string') { + const isCaseSensitive = options?.collatorOptions?.sensitivity === 'case' || caseSensitive; + if(!isCaseSensitive && typeof value === 'string') { if(options?.collatorOptions?.sensitivity === 'base') { const REMOVE_DIACRITICAL_MARKS_REGEXP = /[\u0300-\u036f]/g; diff --git a/packages/devextreme/js/data/query.d.ts b/packages/devextreme/js/data/query.d.ts index 69201a1838ab..5c009faf1be0 100644 --- a/packages/devextreme/js/data/query.d.ts +++ b/packages/devextreme/js/data/query.d.ts @@ -168,11 +168,12 @@ export interface Query { /** * @docid Utils.query - * @publicName query(array) + * @publicName query(array, queryOptions) + * @param2 queryOptions:object * @namespace DevExpress.data * @public */ -declare function query(array: Array): Query; +declare function query(array: Array, queryOptions?: any): Query; /** * @docid Utils.query diff --git a/packages/devextreme/testing/tests/DevExpress.data/queryArray.tests.js b/packages/devextreme/testing/tests/DevExpress.data/queryArray.tests.js index f54dcca70a64..774a20e9ee70 100644 --- a/packages/devextreme/testing/tests/DevExpress.data/queryArray.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.data/queryArray.tests.js @@ -350,6 +350,44 @@ QUnit.test('filter with functional getter', function(assert) { }); }); +QUnit.test('filter with undefined "langParams"', function(assert) { + const input = [{ ID: 'AAA', Name: 'Name 2' }, { ID: 'aaa', Name: 'Name 3' }]; + const filterLength = QUERY(input).filter(['ID', '=', 'aaa']).toArray().length; + assert.equal(filterLength, 2); +}); + +QUnit.test('filter with collatorOptions.sensitivity set to "case"', function(assert) { + const input = [{ ID: 'AAA', Name: 'Name 2' }, { ID: 'aaa', Name: 'Name 3' }]; + + const array = QUERY(input, { + langParams: { + collatorOptions: { + sensitivity: 'case' + } + } + }).filter(['ID', '=', 'aaa']).toArray(); + + assert.equal(array.length, 1); + assert.equal(array[0].ID, 'aaa'); +}); + +QUnit.test('filter with collatorOptions.sensitivity set to "base"', function(assert) { + const input = [{ ID: 'bbb', Name: 'Name 1' }, { ID: 'รกรกรก', Name: 'Name 2' }, { ID: 'aaa', Name: 'Name 3' }]; + + const array = QUERY(input, { + langParams: { + collatorOptions: { + sensitivity: 'base' + } + } + }).filter(['ID', '=', 'aaa']).toArray(); + + assert.equal(array.length, 2); + + const containsUnwantedValue = array.some(item => item.ID === 'bbb'); + assert.false(containsUnwantedValue); +}); + QUnit.test('missing operation means equal', function(assert) { assert.expect(1); diff --git a/packages/devextreme/ts/dx.all.d.ts b/packages/devextreme/ts/dx.all.d.ts index 11e096d667b6..e422e919d6c4 100644 --- a/packages/devextreme/ts/dx.all.d.ts +++ b/packages/devextreme/ts/dx.all.d.ts @@ -6361,9 +6361,9 @@ declare module DevExpress.data { }; } /** - * [descr:Utils.query(array)] + * [descr:Utils.query(array, queryOptions)] */ - export function query(array: Array): Query; + export function query(array: Array, queryOptions?: any): Query; /** * [descr:Utils.query(url, queryOptions)] */