Browse Source

Merge pull request #1727 from nocodb/fix/count-api-and-acl

Fix - count api and acl
pull/1728/head
աɨռɢӄաօռɢ 3 years ago committed by GitHub
parent
commit
3c7bacdd2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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. 11
      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;

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

@ -3,6 +3,8 @@ export default {
creator: '*',
guest: {},
editor: {
hideAllColumns: true,
showAllColumns: true,
auditRowUpdate: true,
passwordChange: true,
// new permissions
@ -124,7 +126,8 @@ export default {
bulkDataDelete: true,
bulkDataDeleteAll: true,
relationDataRemove: true,
relationDataAdd: true
relationDataAdd: true,
dataCount: true
},
commenter: {
formViewGet: true,
@ -171,7 +174,8 @@ export default {
xcModelRowAuditAndCommentList: true,
xcAuditCommentInsert: true,
xcAuditModelCommentsCount: true,
xcExportAsCsv: true
xcExportAsCsv: true,
dataCount: true
},
viewer: {
formViewGet: true,
@ -213,7 +217,8 @@ export default {
relationListAll: true,
indexList: true,
list: true,
xcExportAsCsv: true
xcExportAsCsv: true,
dataCount: true
},
user_new: {
passwordChange: true,

Loading…
Cancel
Save