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 3 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 // eslint-disable-next-line prefer-const
let [logicOp, alias, op, value] = let [logicOp, alias, op, value] =
str.match(/(?:~(and|or|not))?\((.*?),(\w+),(.*)\)/)?.slice(1) || []; str.match(/(?:~(and|or|not))?\((.*?),(\w+),(.*)\)/)?.slice(1) || [];
if (op === 'is') op = 'is' + value; if (op === 'in') value = value.split(',');
else if (op === 'in') value = value.split(',');
return new Filter({ return new Filter({
comparison_op: op, comparison_op: op,

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

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

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

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

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

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

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

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

Loading…
Cancel
Save