Browse Source

Merge pull request #6731 from nocodb/nc-fix/sql-query-errors

fix: Avoid getting unnecessary system column if getHiddenColumn is defined
pull/6749/head
Pranav C 1 year ago committed by GitHub
parent
commit
7c1f60dafb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      packages/nocodb/src/helpers/getAst.ts

22
packages/nocodb/src/helpers/getAst.ts

@ -18,7 +18,7 @@ const getAst = async ({
nested: { ...(query?.nested || {}) },
fieldsSet: new Set(),
},
getHiddenColumn = false,
getHiddenColumn = query?.['getHiddenColumn'],
}: {
query?: RequestQuery;
extractOnlyPrimaries?: boolean;
@ -130,23 +130,25 @@ const getAst = async ({
).ast;
}
let isRequested;
if (getHiddenColumn) {
isRequested =
!isSystemColumn(col) ||
col.column_name === 'created_at' ||
col.column_name === 'updated_at' ||
col.pk;
} else {
} else if (allowedCols && (!includePkByDefault || !col.pk)) {
isRequested =
allowedCols && (!includePkByDefault || !col.pk)
? allowedCols[col.id] &&
(!isSystemColumn(col) || view.show_system_fields || col.pv) &&
(!fields?.length || fields.includes(col.title)) &&
value
: fields?.length
? fields.includes(col.title) && value
: value;
allowedCols[col.id] &&
(!isSystemColumn(col) || view.show_system_fields || col.pv) &&
(!fields?.length || fields.includes(col.title)) &&
value;
} else if (fields?.length) {
isRequested = fields.includes(col.title) && value;
} else {
isRequested = value;
}
if (isRequested || col.pk) await extractDependencies(col, dependencyFields);
return {

Loading…
Cancel
Save