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 // 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;

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

@ -3,6 +3,8 @@ export default {
creator: '*', creator: '*',
guest: {}, guest: {},
editor: { editor: {
hideAllColumns: true,
showAllColumns: true,
auditRowUpdate: true, auditRowUpdate: true,
passwordChange: true, passwordChange: true,
// new permissions // new permissions
@ -124,7 +126,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 +174,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 +217,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