Browse Source

fix: allow count api permission for editor role, add isnot support in xwhere query param

re #1725

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/1727/head
Pranav C 2 years ago
parent
commit
494c7195b9
  1. 3
      packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSqlv2.ts
  2. 26
      packages/nocodb/src/lib/dataMapper/lib/sql/CustomKnex.ts
  3. 14
      packages/nocodb/src/lib/dataMapper/lib/sql/conditionV2.ts
  4. 1
      packages/nocodb/src/lib/noco-models/Filter.ts
  5. 9
      packages/nocodb/src/lib/utils/projectAcl.ts

3
packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSqlv2.ts

@ -2055,8 +2055,7 @@ function extractCondition(nestedArrayConditions, aliasColObjMap) {
// eslint-disable-next-line prefer-const
let [logicOp, alias, op, value] =
str.match(/(?:~(and|or|not))?\((.*?),(\w+),(.*)\)/)?.slice(1) || [];
if (op === 'is') op = 'is' + value;
else if (op === 'in') value = value.split(',');
if (op === 'in') value = value.split(',');
return new Filter({
comparison_op: op,

26
packages/nocodb/src/lib/dataMapper/lib/sql/CustomKnex.ts

@ -432,18 +432,20 @@ const appendWhereCondition = function(
);
break;
case '':
const column = columnAliases[matches[2]] || matches[2];
const operator = opMapping[matches[3]];
const target = matches[4];
if (matches[3] == 'like' && clientType === 'pg') {
// handle uuid case
knexRef[`${key}`](
knexRef?.client.raw(`??::TEXT ${operator} '${target}'`, [
column
])
);
} else {
knexRef[`${key}`](column, operator, target);
{
const column = columnAliases[matches[2]] || matches[2];
const operator = opMapping[matches[3]];
const target = matches[4];
if (matches[3] == 'like' && clientType === 'pg') {
// handle uuid case
knexRef[`${key}`](
knexRef?.client.raw(`??::TEXT ${operator} '${target}'`, [
column
])
);
} else {
knexRef[`${key}`](column, operator, target);
}
}
break;
default:

14
packages/nocodb/src/lib/dataMapper/lib/sql/conditionV2.ts

@ -251,9 +251,19 @@ const parseConditionV2 = async (
else if (filter.value === 'notnull')
qb = qb.whereNotNull(customWhereClause || field);
else if (filter.value === 'empty')
qb = qb.where(customWhereClause || field);
qb = qb.where(customWhereClause || field, '');
else if (filter.value === 'notempty')
qb = qb.whereNot(customWhereClause || field);
qb = qb.whereNot(customWhereClause || field, '');
break;
case 'isnot':
if (filter.value === 'null')
qb = qb.whereNotNull(customWhereClause || field);
else if (filter.value === 'notnull')
qb = qb.whereNull(customWhereClause || field);
else if (filter.value === 'empty')
qb = qb.whereNot(customWhereClause || field, '');
else if (filter.value === 'notempty')
qb = qb.where(customWhereClause || field, '');
break;
case 'lt':
qb = qb.where(field, customWhereClause ? '>' : '<', val);

1
packages/nocodb/src/lib/noco-models/Filter.ts

@ -37,6 +37,7 @@ export default class Filter {
| 'ge'
| 'le'
| 'in'
| 'isnot'
| 'is';
value?: string;

9
packages/nocodb/src/lib/utils/projectAcl.ts

@ -124,7 +124,8 @@ export default {
bulkDataDelete: true,
bulkDataDeleteAll: true,
relationDataRemove: true,
relationDataAdd: true
relationDataAdd: true,
dataCount: true
},
commenter: {
formViewGet: true,
@ -171,7 +172,8 @@ export default {
xcModelRowAuditAndCommentList: true,
xcAuditCommentInsert: true,
xcAuditModelCommentsCount: true,
xcExportAsCsv: true
xcExportAsCsv: true,
dataCount: true
},
viewer: {
formViewGet: true,
@ -213,7 +215,8 @@ export default {
relationListAll: true,
indexList: true,
list: true,
xcExportAsCsv: true
xcExportAsCsv: true,
dataCount: true
},
user_new: {
passwordChange: true,

Loading…
Cancel
Save