@syncfusion/ej2-querybuilder 20.3.56 → 20.4.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -337,7 +337,7 @@ let QueryBuilder = class QueryBuilder extends Component {
337
337
  if (sqlIdx > -1) {
338
338
  const operator = column.operators[j];
339
339
  const operColl = Object.keys(operator);
340
- const values = operColl.map((key) => operator[key]).join(',').split(',');
340
+ const values = operColl.map((key) => operator[`${key}`]).join(',').split(',');
341
341
  const valueIdx = operColl.indexOf('value');
342
342
  this.operators[values[valueIdx]] = values[sqlIdx];
343
343
  }
@@ -728,6 +728,7 @@ let QueryBuilder = class QueryBuilder extends Component {
728
728
  const tooltip = new Tooltip({ content: this.l10n.getConstant('ValidationMessage'),
729
729
  position: 'BottomCenter', cssClass: 'e-querybuilder-error' });
730
730
  tooltip.appendTo(element);
731
+ // eslint-disable-next-line
731
732
  tooltip.open(element);
732
733
  }
733
734
  /**
@@ -785,8 +786,9 @@ let QueryBuilder = class QueryBuilder extends Component {
785
786
  if (rule.rules[index].value instanceof Array) {
786
787
  valArray = rule.rules[index].value;
787
788
  }
788
- if (excludeOprs.indexOf(rule.rules[index].operator) < 0 && (isNullOrUndefined(rule.rules[index].value) &&
789
- rule.rules[index].type !== 'date') || rule.rules[index].value === '' ||
789
+ if (excludeOprs.indexOf(rule.rules[index].operator) < 0 &&
790
+ (isNullOrUndefined(rule.rules[index].value) &&
791
+ rule.rules[index].type !== 'date') || rule.rules[index].value === '' ||
790
792
  (rule.rules[index].value instanceof Array && valArray.length < 1)) {
791
793
  const valElem = tempElem.querySelectorAll('.e-rule-value .e-control');
792
794
  isValid = false;
@@ -864,7 +866,7 @@ let QueryBuilder = class QueryBuilder extends Component {
864
866
  groupElem.appendChild(grpBodyElem);
865
867
  // create button group in OR and AND process
866
868
  if (!this.headerTemplate) {
867
- glueElem = this.createElement('div', { attrs: { class: 'e-lib e-btn-group' } });
869
+ glueElem = this.createElement('div', { attrs: { class: 'e-lib e-btn-group', role: 'group' } });
868
870
  if (this.enableNotCondition) {
869
871
  inputElem = this.createElement('button', { attrs: { type: 'button', class: 'e-qb-toggle' } });
870
872
  glueElem.appendChild(inputElem);
@@ -1743,29 +1745,29 @@ let QueryBuilder = class QueryBuilder extends Component {
1743
1745
  for (let j = 0, jLen = fieldColl.length; j < jLen; j++) {
1744
1746
  fieldStr = fieldColl[j];
1745
1747
  if (fieldColl.length === (j + 1)) {
1746
- value = dataObj[fieldStr];
1747
- if (Number(dataObj[fieldStr]) === dataObj[fieldStr] && dataObj[fieldStr] % 1 !== 0) {
1748
- value = dataObj[fieldStr].toString();
1748
+ value = dataObj[`${fieldStr}`];
1749
+ if (Number(dataObj[`${fieldStr}`]) === dataObj[`${fieldStr}`] && dataObj[`${fieldStr}`] % 1 !== 0) {
1750
+ value = dataObj[`${fieldStr}`].toString();
1749
1751
  }
1750
1752
  }
1751
1753
  else {
1752
- dataObj = dataObj[fieldStr];
1754
+ dataObj = dataObj[`${fieldStr}`];
1753
1755
  }
1754
1756
  }
1755
1757
  }
1756
1758
  else {
1757
- value = dataSource[i][field];
1758
- if (Number(dataSource[i][field]) === dataSource[i][field] && dataSource[i][field] % 1 !== 0) {
1759
- value = dataSource[i][field].toString();
1759
+ value = dataSource[i][`${field}`];
1760
+ if (Number(dataSource[i][`${field}`]) === dataSource[i][`${field}`] && dataSource[i][`${field}`] % 1 !== 0) {
1761
+ value = dataSource[i][`${field}`].toString();
1760
1762
  }
1761
1763
  }
1762
1764
  if (!(value in original)) {
1763
- original[value] = 1;
1765
+ original[`${value}`] = 1;
1764
1766
  if (fieldColl.length > 1) {
1765
1767
  this.createNestedObject(data, fieldColl, value);
1766
1768
  }
1767
1769
  else {
1768
- data[field] = value;
1770
+ data[`${field}`] = value;
1769
1771
  }
1770
1772
  result.push(data);
1771
1773
  }
@@ -1779,9 +1781,9 @@ let QueryBuilder = class QueryBuilder extends Component {
1779
1781
  for (let k = 0; k < lastIndex; ++k) {
1780
1782
  key = fieldColl[k];
1781
1783
  if (!(key in obj)) {
1782
- obj[key] = {};
1784
+ obj[`${key}`] = {};
1783
1785
  }
1784
- obj = obj[key];
1786
+ obj = obj[`${key}`];
1785
1787
  }
1786
1788
  obj[fieldColl[lastIndex]] = value;
1787
1789
  }
@@ -1793,28 +1795,28 @@ let QueryBuilder = class QueryBuilder extends Component {
1793
1795
  const isNested = field.indexOf(this.separator);
1794
1796
  for (let i = 0, iLen = dataSource.length; i < iLen; i++) {
1795
1797
  if (isNested === 0) {
1796
- value = dataSource[i][field];
1798
+ value = dataSource[i][`${field}`];
1797
1799
  }
1798
1800
  else {
1799
1801
  nest = field.split(this.separator);
1800
1802
  // eslint-disable-next-line @typescript-eslint/tslint/config
1801
1803
  nest.forEach(element => {
1802
1804
  if (value) {
1803
- value = value[element];
1805
+ value = value[`${element}`];
1804
1806
  }
1805
1807
  else {
1806
- value = dataSource[i][element];
1808
+ value = dataSource[i][`${element}`];
1807
1809
  }
1808
1810
  });
1809
1811
  }
1810
- if (Number(dataSource[i][field]) === dataSource[i][field] && dataSource[i][field] % 1 !== 0) {
1811
- value = dataSource[i][field].toString();
1812
+ if (Number(dataSource[i][`${field}`]) === dataSource[i][`${field}`] && dataSource[i][`${field}`] % 1 !== 0) {
1813
+ value = dataSource[i][`${field}`].toString();
1812
1814
  }
1813
1815
  const data = {};
1814
1816
  if (!(value in original)) {
1815
- original[value] = 1;
1817
+ original[`${value}`] = 1;
1816
1818
  if (isNested === 0) {
1817
- data[field] = value;
1819
+ data[`${field}`] = value;
1818
1820
  }
1819
1821
  else {
1820
1822
  data[nest[nest.length - 1]] = value;
@@ -2556,7 +2558,8 @@ let QueryBuilder = class QueryBuilder extends Component {
2556
2558
  const column = this.fieldMode === 'DropdownTree' ? this.getColumn(dropDownObj.value[0])
2557
2559
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2558
2560
  : this.getColumn(dropDownObj.value);
2559
- if (!this.isImportRules && rule.rules[index].field && rule.rules[index].field.toLowerCase() !== column.field.toLowerCase()) {
2561
+ if (!this.isImportRules && rule.rules[index].field &&
2562
+ rule.rules[index].field.toLowerCase() !== column.field.toLowerCase()) {
2560
2563
  if (!(ruleElem.querySelectorAll('.e-template')) && !(operator.indexOf('null') > -1)
2561
2564
  || (operator.indexOf('empty') > -1)) {
2562
2565
  rule.rules[index].value = '';
@@ -3163,6 +3166,8 @@ let QueryBuilder = class QueryBuilder extends Component {
3163
3166
  StartsWith: 'Starts With',
3164
3167
  EndsWith: 'Ends With',
3165
3168
  Contains: 'Contains',
3169
+ NotLike: 'Not Like',
3170
+ Like: 'Like',
3166
3171
  Equal: 'Equal',
3167
3172
  NotEqual: 'Not Equal',
3168
3173
  LessThan: 'Less Than',
@@ -3247,6 +3252,16 @@ let QueryBuilder = class QueryBuilder extends Component {
3247
3252
  isnull: 'IS NULL', isnotnull: 'IS NOT NULL', isempty: 'IS EMPTY', isnotempty: 'IS NOT EMPTY', notstartswith: 'NOT LIKE',
3248
3253
  notendswith: 'NOT LIKE', notcontains: 'NOT LIKE'
3249
3254
  };
3255
+ this.sqlOperators = {
3256
+ equal: '=', notequal: '!=', greaterthan: '>', greaterthanorequal: '>=', lessthan: '<', in: this.l10n.getConstant('In').toUpperCase(),
3257
+ notin: this.l10n.getConstant('NotIn').toUpperCase(), lessthanorequal: '<=', startswith: this.l10n.getConstant('Like').toUpperCase(),
3258
+ endswith: this.l10n.getConstant('Like').toUpperCase(), between: this.l10n.getConstant('Between').toUpperCase(),
3259
+ notbetween: this.l10n.getConstant('NotBetween').toUpperCase(), contains: this.l10n.getConstant('Like').toUpperCase(),
3260
+ isnull: this.l10n.getConstant('IsNull').toUpperCase(), isnotnull: this.l10n.getConstant('IsNotNull').toUpperCase(),
3261
+ isempty: this.l10n.getConstant('IsEmpty').toUpperCase(), isnotempty: this.l10n.getConstant('IsNotEmpty').toUpperCase(),
3262
+ notstartswith: this.l10n.getConstant('NotLike').toUpperCase(), notendswith: this.l10n.getConstant('NotLike').toUpperCase(),
3263
+ notcontains: this.l10n.getConstant('NotLike').toUpperCase()
3264
+ };
3250
3265
  if (!this.fields) {
3251
3266
  this.fields = { text: 'label', value: 'field' };
3252
3267
  }
@@ -3337,7 +3352,7 @@ let QueryBuilder = class QueryBuilder extends Component {
3337
3352
  EventHandler.remove(this.element, 'keydown', this.keyBoardHandler);
3338
3353
  }
3339
3354
  getParentGroup(target, isParent) {
3340
- const groupLevel = (target instanceof Element) ? this.levelColl[target.id] : this.levelColl[target];
3355
+ const groupLevel = (target instanceof Element) ? this.levelColl[target.id] : this.levelColl[`${target}`];
3341
3356
  const len = isParent ? groupLevel.length - 1 : groupLevel.length;
3342
3357
  let rule = this.rule;
3343
3358
  for (let i = 0; i < len; i++) {
@@ -3497,6 +3512,7 @@ let QueryBuilder = class QueryBuilder extends Component {
3497
3512
  err = [];
3498
3513
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3499
3514
  const error = 'error';
3515
+ // eslint-disable-next-line
3500
3516
  err[error] = error;
3501
3517
  }
3502
3518
  // eslint-enable
@@ -3658,6 +3674,9 @@ let QueryBuilder = class QueryBuilder extends Component {
3658
3674
  else {
3659
3675
  rule = { 'condition': rule.condition, 'rules': rule.rules };
3660
3676
  }
3677
+ if (rule.rules.length === 0) {
3678
+ rule = {};
3679
+ }
3661
3680
  }
3662
3681
  }
3663
3682
  return rule;
@@ -3866,7 +3885,8 @@ let QueryBuilder = class QueryBuilder extends Component {
3866
3885
  if (i === 0) {
3867
3886
  if (isDateFilter || (oper.indexOf('in') > -1 || oper.indexOf('between') > -1 || oper.indexOf('null') > -1 ||
3868
3887
  oper.indexOf('empty') > -1) && oper.indexOf('contains') < 0) {
3869
- pred = isDateFilter ? this.datePredicate(ruleColl[i], ruleValue) : this.arrayPredicate(ruleColl[i]);
3888
+ pred = isDateFilter ? this.datePredicate(ruleColl[i], ruleValue) :
3889
+ this.arrayPredicate(ruleColl[i]);
3870
3890
  }
3871
3891
  else {
3872
3892
  const value = ruleValue;
@@ -4328,7 +4348,7 @@ let QueryBuilder = class QueryBuilder extends Component {
4328
4348
  }
4329
4349
  return false;
4330
4350
  }
4331
- getSqlString(rules, enableEscape, queryStr) {
4351
+ getSqlString(rules, enableEscape, queryStr, sqlLocale) {
4332
4352
  let isRoot = false;
4333
4353
  if (!queryStr && queryStr !== '') {
4334
4354
  queryStr = '';
@@ -4339,92 +4359,100 @@ let QueryBuilder = class QueryBuilder extends Component {
4339
4359
  }
4340
4360
  let condition = rules.condition;
4341
4361
  if (rules.not) {
4362
+ let rulesNotCondition;
4342
4363
  if (isRoot) {
4343
- queryStr += 'NOT (';
4364
+ rulesNotCondition = sqlLocale ? this.l10n.getConstant('NOT').toUpperCase() + ' (' : 'NOT (';
4365
+ queryStr += rulesNotCondition;
4344
4366
  }
4345
4367
  else {
4346
- queryStr += ' NOT (';
4368
+ rulesNotCondition = sqlLocale ? ' ' + this.l10n.getConstant('NOT').toUpperCase() + ' (' : ' NOT (';
4369
+ queryStr += rulesNotCondition;
4347
4370
  }
4348
4371
  }
4349
- for (let j = 0, jLen = rules.rules.length; j < jLen; j++) {
4350
- if (rules.rules[j].rules) {
4351
- queryStr = this.getSqlString(rules.rules[j], enableEscape, queryStr);
4352
- }
4353
- else {
4354
- const rule = rules.rules[j];
4355
- let valueStr = '';
4356
- if (rule.value instanceof Array) {
4357
- if (rule.operator.toString().indexOf('between') > -1) {
4358
- if (rule.type === 'date' && !this.isDateFunction(rule.value[0])) {
4359
- valueStr += '"' + rule.value[0] + '" AND "' + rule.value[1] + '"';
4372
+ if (rules.rules) {
4373
+ for (let j = 0, jLen = rules.rules.length; j < jLen; j++) {
4374
+ if (rules.rules[j].rules) {
4375
+ queryStr = this.getSqlString(rules.rules[j], enableEscape, queryStr, sqlLocale);
4376
+ }
4377
+ else {
4378
+ const rule = rules.rules[j];
4379
+ let valueStr = '';
4380
+ const ruleOpertor = sqlLocale ? this.sqlOperators[rule.operator] : this.operators[rule.operator];
4381
+ if (rule.value instanceof Array) {
4382
+ if (rule.operator.toString().indexOf('between') > -1) {
4383
+ const ruleCondition = sqlLocale ? ' ' + this.l10n.getConstant('AND').toUpperCase() + ' ' : ' ' + 'AND' + ' ';
4384
+ if (rule.type === 'date' && !this.isDateFunction(rule.value[0])) {
4385
+ valueStr += '"' + rule.value[0] + '"' + ruleCondition + '"' + rule.value[1] + '"';
4386
+ }
4387
+ else {
4388
+ valueStr += rule.value[0] + ruleCondition + rule.value[1];
4389
+ }
4360
4390
  }
4361
4391
  else {
4362
- valueStr += rule.value[0] + ' AND ' + rule.value[1];
4392
+ if (typeof rule.value[0] === 'string' && rule.value !== null) {
4393
+ valueStr += '("' + rule.value[0] + '"';
4394
+ for (let k = 1, kLen = rule.value.length; k < kLen; k++) {
4395
+ valueStr += ',"' + rule.value[k] + '"';
4396
+ }
4397
+ valueStr += ')';
4398
+ }
4399
+ else {
4400
+ valueStr += '(' + rule.value + ')';
4401
+ }
4363
4402
  }
4364
4403
  }
4365
4404
  else {
4366
- if (typeof rule.value[0] === 'string' && rule.value !== null) {
4367
- valueStr += '("' + rule.value[0] + '"';
4368
- for (let k = 1, kLen = rule.value.length; k < kLen; k++) {
4369
- valueStr += ',"' + rule.value[k] + '"';
4370
- }
4371
- valueStr += ')';
4405
+ if (rule.operator.toString().indexOf('startswith') > -1) {
4406
+ valueStr += rule.value ? '("' + rule.value + '%")' : '(' + rule.value + ')';
4407
+ }
4408
+ else if (rule.operator.toString().indexOf('endswith') > -1) {
4409
+ valueStr += rule.value ? '("%' + rule.value + '")' : '(' + rule.value + ')';
4410
+ }
4411
+ else if (rule.operator.toString().indexOf('contains') > -1) {
4412
+ valueStr += rule.value ? '("%' + rule.value + '%")' : '(' + rule.value + ')';
4372
4413
  }
4373
4414
  else {
4374
- valueStr += '(' + rule.value + ')';
4415
+ if (rule.type === 'number' || typeof rule.value === 'boolean' || rule.value === null) {
4416
+ valueStr += rule.value;
4417
+ }
4418
+ else {
4419
+ valueStr += '"' + rule.value + '"';
4420
+ }
4375
4421
  }
4376
4422
  }
4377
- }
4378
- else {
4379
- if (rule.operator.toString().indexOf('startswith') > -1) {
4380
- valueStr += rule.value ? '("' + rule.value + '%")' : '(' + rule.value + ')';
4381
- }
4382
- else if (rule.operator.toString().indexOf('endswith') > -1) {
4383
- valueStr += rule.value ? '("%' + rule.value + '")' : '(' + rule.value + ')';
4384
- }
4385
- else if (rule.operator.toString().indexOf('contains') > -1) {
4386
- valueStr += rule.value ? '("%' + rule.value + '%")' : '(' + rule.value + ')';
4387
- }
4388
- else {
4389
- if (rule.type === 'number' || typeof rule.value === 'boolean' || rule.value === null) {
4390
- valueStr += rule.value;
4423
+ if (rule.operator.toString().indexOf('null') > -1 || (rule.operator.toString().indexOf('empty') > -1)) {
4424
+ if (enableEscape) {
4425
+ rule.field = '`' + rule.field + '`';
4391
4426
  }
4392
4427
  else {
4393
- valueStr += '"' + rule.value + '"';
4428
+ if (rule.field.indexOf(' ') > -1) {
4429
+ rule.field = '"' + rule.field + '"';
4430
+ }
4394
4431
  }
4395
- }
4396
- }
4397
- if (rule.operator.toString().indexOf('null') > -1 || (rule.operator.toString().indexOf('empty') > -1)) {
4398
- if (enableEscape) {
4399
- rule.field = '`' + rule.field + '`';
4432
+ queryStr += rule.field + ' ' + ruleOpertor;
4400
4433
  }
4401
4434
  else {
4402
- if (rule.field.indexOf(' ') > -1) {
4403
- rule.field = '"' + rule.field + '"';
4435
+ if (enableEscape) {
4436
+ rule.field = '`' + rule.field + '`';
4404
4437
  }
4405
- }
4406
- queryStr += rule.field + ' ' + this.operators[rule.operator];
4407
- }
4408
- else {
4409
- if (enableEscape) {
4410
- rule.field = '`' + rule.field + '`';
4411
- }
4412
- else {
4413
- if (rule.field.indexOf(' ') > -1) {
4414
- rule.field = '"' + rule.field + '"';
4438
+ else {
4439
+ if (rule.field.indexOf(' ') > -1) {
4440
+ rule.field = '"' + rule.field + '"';
4441
+ }
4415
4442
  }
4443
+ queryStr += rule.field + ' ' + ruleOpertor + ' ' + valueStr;
4444
+ }
4445
+ if (rule.condition && rule.condition !== '') {
4446
+ condition = rule.condition;
4416
4447
  }
4417
- queryStr += rule.field + ' ' + this.operators[rule.operator] + ' ' + valueStr;
4418
- }
4419
- if (rule.condition && rule.condition !== '') {
4420
- condition = rule.condition;
4421
4448
  }
4422
- }
4423
- if (j !== jLen - 1) {
4424
- if (condition === '') {
4425
- condition = rules.rules[j].condition;
4449
+ if (j !== jLen - 1) {
4450
+ if (condition === '') {
4451
+ condition = rules.rules[j].condition;
4452
+ }
4453
+ condition = sqlLocale ? this.l10n.getConstant(condition.toUpperCase()).toUpperCase() : condition.toUpperCase();
4454
+ queryStr += ' ' + condition + ' ';
4426
4455
  }
4427
- queryStr += ' ' + condition.toUpperCase() + ' ';
4428
4456
  }
4429
4457
  }
4430
4458
  if (!isRoot) {
@@ -4439,24 +4467,26 @@ let QueryBuilder = class QueryBuilder extends Component {
4439
4467
  * Sets the rules from the sql query.
4440
4468
  *
4441
4469
  * @param {string} sqlString - 'sql String' to be passed to set the rule.
4470
+ * @param {boolean} sqlLocale - Set `true` if Localization for Sql query.
4442
4471
  * @returns {void}
4443
4472
  */
4444
- setRulesFromSql(sqlString) {
4473
+ setRulesFromSql(sqlString, sqlLocale) {
4445
4474
  sqlString = sqlString.replace(/`/g, '');
4446
- const ruleModel = this.getRulesFromSql(sqlString);
4475
+ const ruleModel = this.getRulesFromSql(sqlString, sqlLocale);
4447
4476
  this.setRules({ condition: ruleModel.condition, not: ruleModel.not, rules: ruleModel.rules });
4448
4477
  }
4449
4478
  /**
4450
4479
  * Get the rules from SQL query.
4451
4480
  *
4452
4481
  * @param {string} sqlString - 'sql String' to be passed to get the rule.
4482
+ * @param {boolean} sqlLocale - Set `true` if Localization for Sql query.
4453
4483
  * @returns {object} - Rules from SQL query
4454
4484
  */
4455
- getRulesFromSql(sqlString) {
4485
+ getRulesFromSql(sqlString, sqlLocale) {
4456
4486
  this.parser = [];
4457
- this.sqlParser(sqlString);
4487
+ this.sqlParser(sqlString, sqlLocale);
4458
4488
  this.rule = { condition: 'and', not: false, rules: [] };
4459
- const rule = this.processParser(this.parser, this.rule, [0]);
4489
+ const rule = this.processParser(this.parser, this.rule, [0], sqlLocale);
4460
4490
  if (this.enableNotCondition) {
4461
4491
  return { condition: rule.condition, not: rule.not, rules: rule.rules };
4462
4492
  }
@@ -4469,33 +4499,51 @@ let QueryBuilder = class QueryBuilder extends Component {
4469
4499
  *
4470
4500
  * @param {RuleModel} rule - 'rule' to be passed to get the sql.
4471
4501
  * @param {boolean} allowEscape - Set `true` if it exclude the escape character.
4502
+ * @param {boolean} sqlLocale - Set `true` if Localization for Sql query.
4472
4503
  * @returns {object} - Sql query from rules.
4473
4504
  */
4474
- getSqlFromRules(rule, allowEscape) {
4505
+ getSqlFromRules(rule, allowEscape, sqlLocale) {
4475
4506
  if (!rule) {
4476
4507
  rule = this.getValidRules();
4477
4508
  }
4478
4509
  rule = this.getRuleCollection(rule, false);
4479
- return this.getSqlString(this.getValidRules(rule), allowEscape).replace(/"/g, '\'');
4510
+ return this.getSqlString(this.getValidRules(rule), allowEscape, null, sqlLocale).replace(/"/g, '\'');
4480
4511
  }
4481
- sqlParser(sqlString) {
4512
+ sqlParser(sqlString, sqlLocale) {
4482
4513
  let st = 0;
4483
4514
  let str;
4484
4515
  do {
4485
4516
  str = sqlString.slice(st);
4486
- st += this.parseSqlStrings(str);
4517
+ st += this.parseSqlStrings(str, sqlLocale);
4487
4518
  } while (str !== '');
4488
4519
  return this.parser;
4489
4520
  }
4490
- parseSqlStrings(sqlString) {
4521
+ parseSqlStrings(sqlString, sqlLocale) {
4491
4522
  const operators = ['=', '!=', '<=', '>=', '<', '>'];
4492
- const conditions = ['AND', 'OR', 'NOT'];
4493
- const subOp = ['IN', 'NOT IN', 'LIKE', 'NOT LIKE', 'BETWEEN', 'NOT BETWEEN', 'IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY'];
4523
+ let conditions;
4524
+ if (sqlLocale) {
4525
+ conditions = [this.l10n.getConstant('AND').toUpperCase(), this.l10n.getConstant('OR').toUpperCase(), this.l10n.getConstant('NOT').toUpperCase()];
4526
+ }
4527
+ else {
4528
+ conditions = ['AND', 'OR', 'NOT'];
4529
+ }
4530
+ let subOp;
4531
+ if (sqlLocale) {
4532
+ subOp = [this.l10n.getConstant('In').toUpperCase(), this.l10n.getConstant('NotIn').toUpperCase(),
4533
+ this.l10n.getConstant('Like').toUpperCase(), this.l10n.getConstant('NotLike').toUpperCase(),
4534
+ this.l10n.getConstant('Between').toUpperCase(), this.l10n.getConstant('NotBetween').toUpperCase(),
4535
+ this.l10n.getConstant('IsNull').toUpperCase(), this.l10n.getConstant('IsNotNull').toUpperCase(),
4536
+ this.l10n.getConstant('IsEmpty').toUpperCase(), this.l10n.getConstant('IsNotEmpty').toUpperCase()];
4537
+ }
4538
+ else {
4539
+ subOp = ['IN', 'NOT IN', 'LIKE', 'NOT LIKE', 'BETWEEN', 'NOT BETWEEN', 'IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY'];
4540
+ }
4494
4541
  let regexStr;
4495
4542
  let regex;
4496
4543
  let matchValue;
4497
4544
  for (let i = 0, iLen = operators.length; i < iLen; i++) {
4498
4545
  regexStr = /^\w+$/.test(operators[i]) ? '\\b' : '';
4546
+ // eslint-disable-next-line
4499
4547
  regex = new RegExp('^(' + operators[i] + ')' + regexStr, 'ig');
4500
4548
  if (regex.exec(sqlString)) {
4501
4549
  this.parser.push(['Operators', operators[i].toLowerCase()]);
@@ -4506,6 +4554,7 @@ let QueryBuilder = class QueryBuilder extends Component {
4506
4554
  if (!lastPasrser || (lastPasrser && lastPasrser[0] !== 'Literal')) {
4507
4555
  for (let i = 0, iLen = conditions.length; i < iLen; i++) {
4508
4556
  regexStr = /^\w+$/.test(conditions[i]) ? '\\b' : '';
4557
+ // eslint-disable-next-line
4509
4558
  regex = new RegExp('^(' + conditions[i] + ')' + regexStr, 'ig');
4510
4559
  if (regex.exec(sqlString)) {
4511
4560
  this.parser.push(['Conditions', conditions[i].toLowerCase()]);
@@ -4515,6 +4564,7 @@ let QueryBuilder = class QueryBuilder extends Component {
4515
4564
  }
4516
4565
  for (let i = 0, iLen = subOp.length; i < iLen; i++) {
4517
4566
  regexStr = /^\w+$/.test(subOp[i]) ? '\\b' : '';
4567
+ // eslint-disable-next-line
4518
4568
  regex = new RegExp('^(' + subOp[i] + ')' + regexStr, 'ig');
4519
4569
  if (regex.exec(sqlString)) {
4520
4570
  this.parser.push(['SubOperators', subOp[i].toLowerCase()]);
@@ -4557,31 +4607,40 @@ let QueryBuilder = class QueryBuilder extends Component {
4557
4607
  this.parser.push(['Literal', matchValue]);
4558
4608
  return matchValue.length + 2;
4559
4609
  }
4560
- if (this.checkNumberLiteral(sqlString)) {
4610
+ if (this.checkNumberLiteral(sqlString, sqlLocale)) {
4611
+ // eslint-disable-next-line
4561
4612
  matchValue = /^[0-9]+(\.[0-9]+)?/.exec(sqlString)[0];
4562
4613
  this.parser.push(['Literal', matchValue]);
4563
4614
  return matchValue.length;
4564
4615
  }
4565
4616
  //String
4617
+ // eslint-disable-next-line
4566
4618
  if (/^'((?:[^\\']+?|\\.|'')*)'(?!')/.exec(sqlString)) {
4619
+ // eslint-disable-next-line
4567
4620
  matchValue = /^'((?:[^\\']+?|\\.|'')*)'(?!')/.exec(sqlString)[0];
4568
4621
  this.parser.push(['String', matchValue]);
4569
4622
  return matchValue.length;
4570
4623
  }
4571
4624
  //Double String
4625
+ // eslint-disable-next-line
4572
4626
  if (/^"([^\\"]*(?:\\.[^\\"]*)*)"/.exec(sqlString)) {
4627
+ // eslint-disable-next-line
4573
4628
  matchValue = /^"([^\\"]*(?:\\.[^\\"]*)*)"/.exec(sqlString)[0];
4574
4629
  this.parser.push(['DoubleString', matchValue]);
4575
4630
  return matchValue.length;
4576
4631
  }
4577
4632
  //Number
4633
+ // eslint-disable-next-line
4578
4634
  if (/^[0-9]+(\.[0-9]+)?/.exec(sqlString)) {
4635
+ // eslint-disable-next-line
4579
4636
  matchValue = /^[0-9]+(\.[0-9]+)?/.exec(sqlString)[0];
4580
4637
  this.parser.push(['Number', matchValue]);
4581
4638
  return matchValue.length;
4582
4639
  }
4583
4640
  //Negative Number
4641
+ // eslint-disable-next-line
4584
4642
  if (/^-?[0-9]+(\.[0-9]+)?/.exec(sqlString)) {
4643
+ // eslint-disable-next-line
4585
4644
  matchValue = /^-?[0-9]+(\.[0-9]+)?/.exec(sqlString)[0];
4586
4645
  this.parser.push(['Number', matchValue]);
4587
4646
  return matchValue.length;
@@ -4601,31 +4660,51 @@ let QueryBuilder = class QueryBuilder extends Component {
4601
4660
  }
4602
4661
  return false;
4603
4662
  }
4604
- checkNumberLiteral(sqlString) {
4663
+ checkNumberLiteral(sqlString, sqlLocale) {
4605
4664
  const lastParser = this.parser[this.parser.length - 1];
4606
4665
  if (!lastParser) {
4607
4666
  return true;
4608
4667
  }
4609
4668
  else {
4669
+ // eslint-disable-next-line
4610
4670
  if (/^[0-9]+(\.[0-9]+)?/.exec(sqlString)) {
4611
4671
  const secParser = this.parser[this.parser.length - 2];
4612
4672
  const betweenParser = this.parser[this.parser.length - 3];
4613
4673
  if (lastParser[0] === 'Left' && (secParser && secParser[0] === 'Conditions')) {
4614
4674
  return true;
4615
4675
  }
4616
- if (lastParser[0] === 'Conditions' && (betweenParser && betweenParser[1].indexOf('between') < 0)) {
4676
+ const betweenOperator = sqlLocale ? this.l10n.getConstant('Between').toLowerCase() : 'between';
4677
+ if (lastParser[0] === 'Conditions' && (betweenParser && betweenParser[1].indexOf(betweenOperator) < 0)) {
4617
4678
  return true;
4618
4679
  }
4619
4680
  }
4620
4681
  }
4621
4682
  return false;
4622
4683
  }
4623
- getOperator(value, operator) {
4684
+ getOperator(value, operator, sqlLocale) {
4624
4685
  const operators = {
4625
4686
  '=': 'equal', '!=': 'notequal', '<': 'lessthan', '>': 'greaterthan', '<=': 'lessthanorequal',
4626
4687
  '>=': 'greaterthanorequal', 'in': 'in', 'not in': 'notin', 'between': 'between', 'not between': 'notbetween',
4627
4688
  'is empty': 'isempty', 'is null': 'isnull', 'is not null': 'isnotnull', 'is not empty': 'isnotempty'
4628
4689
  };
4690
+ if (sqlLocale) {
4691
+ const localeOperator = Object.keys(this.sqlOperators);
4692
+ for (let i = 0; i < localeOperator.length; i++) {
4693
+ if (this.sqlOperators[localeOperator[i]] === operator.toUpperCase()) {
4694
+ if (value && value.indexOf('%') === 0 && value[value.length - 1] === '%') {
4695
+ return (localeOperator[i] === 'notcontains') ? 'notcontains' : 'contains';
4696
+ }
4697
+ else if (value && value.indexOf('%') !== 0 && value.indexOf('%') === value.length - 1) {
4698
+ return (localeOperator[i] === 'notstartswith') ? 'notstartswith' : 'startswith';
4699
+ }
4700
+ else if (value && value.indexOf('%') === 0 && value.indexOf('%') !== value.length - 1) {
4701
+ return (localeOperator[i] === 'notendswith') ? 'notendswith' : 'endswith';
4702
+ }
4703
+ return localeOperator[i];
4704
+ }
4705
+ }
4706
+ return null;
4707
+ }
4629
4708
  if (value) {
4630
4709
  if (value.indexOf('%') === 0 && value[value.length - 1] === '%') {
4631
4710
  return (operator === 'not like') ? 'notcontains' : 'contains';
@@ -4645,11 +4724,14 @@ let QueryBuilder = class QueryBuilder extends Component {
4645
4724
  return 'equal';
4646
4725
  }
4647
4726
  }
4648
- return operators[operator];
4727
+ return operators[`${operator}`];
4649
4728
  }
4650
4729
  getTypeFromColumn(rules) {
4651
4730
  const columnData = this.getColumn(rules.field);
4652
- return columnData.type;
4731
+ if (!isNullOrUndefined(columnData)) {
4732
+ return columnData.type;
4733
+ }
4734
+ return null;
4653
4735
  }
4654
4736
  getLabelFromColumn(field) {
4655
4737
  let label = '';
@@ -4682,7 +4764,7 @@ let QueryBuilder = class QueryBuilder extends Component {
4682
4764
  }
4683
4765
  return this.getColumn(fieldName).label;
4684
4766
  }
4685
- processParser(parser, rules, levelColl) {
4767
+ processParser(parser, rules, levelColl, sqlLocale) {
4686
4768
  let j;
4687
4769
  let jLen;
4688
4770
  let rule;
@@ -4701,18 +4783,27 @@ let QueryBuilder = class QueryBuilder extends Component {
4701
4783
  rule = { label: parser[i][1], field: parser[i][1] };
4702
4784
  if (parser[i + 1][0] === 'SubOperators') {
4703
4785
  if (parser[i + 1][1].indexOf('null') > -1 || parser[i + 1][1].indexOf('empty') > -1) {
4704
- rule.operator = this.getOperator(' ', parser[i + 1][1]);
4786
+ rule.operator = this.getOperator(' ', parser[i + 1][1], sqlLocale);
4705
4787
  rule.value = null;
4706
4788
  rule.type = this.getTypeFromColumn(rule);
4707
4789
  }
4708
4790
  else {
4709
4791
  const oper = parser[i + 3][1] ? parser[i + 3][1].replace(/'/g, '') : parser[i + 3][1];
4710
- rule.operator = this.getOperator(oper, parser[i + 1][1]);
4792
+ rule.operator = this.getOperator(oper, parser[i + 1][1], sqlLocale);
4711
4793
  }
4712
4794
  operator = parser[i + 1][1];
4713
4795
  i++;
4714
4796
  j = i + 1;
4715
4797
  jLen = iLen;
4798
+ if (sqlLocale && rule.operator === 'contains' || rule.operator === 'startswith' || rule.operator === 'endswith') {
4799
+ operator = 'like';
4800
+ }
4801
+ else if (sqlLocale && rule.operator === 'notcontains' || rule.operator === 'notstartswith' || rule.operator === 'notendswith') {
4802
+ operator = 'not like';
4803
+ }
4804
+ else if (sqlLocale) {
4805
+ operator = rule.operator;
4806
+ }
4716
4807
  for (j = i + 1; j < jLen; j++) {
4717
4808
  if (operator.indexOf('between') < 0 && parser[j][0] === 'Left') {
4718
4809
  isLeftOpened = true;
@@ -4778,7 +4869,7 @@ let QueryBuilder = class QueryBuilder extends Component {
4778
4869
  }
4779
4870
  }
4780
4871
  else if (parser[i + 1][0] === 'Operators') {
4781
- rule.operator = this.getOperator(parser[i + 2][1], parser[i + 1][1]);
4872
+ rule.operator = this.getOperator(parser[i + 2][1], parser[i + 1][1], sqlLocale);
4782
4873
  if (parser[i + 2][0] === 'Number') {
4783
4874
  rule.type = 'number';
4784
4875
  rule.value = Number(parser[i + 2][1]);
@@ -4792,7 +4883,7 @@ let QueryBuilder = class QueryBuilder extends Component {
4792
4883
  rules.rules.push(rule);
4793
4884
  }
4794
4885
  else if (parser[i][0] === 'Left') {
4795
- if (!(parser[0][0] === 'Left') && parser[i - 1][1] === 'not') {
4886
+ if (!(parser[0][0] === 'Left') && (parser[i - 1][1] === 'not' || sqlLocale && this.l10n.getConstant('NOT').toLowerCase() === parser[i - 1][1])) {
4796
4887
  continue;
4797
4888
  }
4798
4889
  this.parser = parser.splice(i + 1, iLen - (i + 1));
@@ -4811,11 +4902,11 @@ let QueryBuilder = class QueryBuilder extends Component {
4811
4902
  }
4812
4903
  levelColl.push(grpCount);
4813
4904
  rules.rules.push(subRules);
4814
- subRules = this.processParser(this.parser, subRules, levelColl);
4905
+ subRules = this.processParser(this.parser, subRules, levelColl, sqlLocale);
4815
4906
  return rules;
4816
4907
  }
4817
4908
  else if (parser[i][0] === 'Conditions') {
4818
- if (parser[i][1] === 'not') {
4909
+ if (parser[i][1] === 'not' || (sqlLocale && this.l10n.getConstant('NOT').toLowerCase() === parser[i][1])) {
4819
4910
  rules.not = true;
4820
4911
  }
4821
4912
  else {
@@ -4830,7 +4921,7 @@ let QueryBuilder = class QueryBuilder extends Component {
4830
4921
  for (l = 0; l < lLen; l++) {
4831
4922
  rules = this.findGroupByIdx(levelColl[l], rules, l === 0);
4832
4923
  }
4833
- return this.processParser(this.parser, rules, levelColl);
4924
+ return this.processParser(this.parser, rules, levelColl, sqlLocale);
4834
4925
  }
4835
4926
  }
4836
4927
  return rules;