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

Loading…
Cancel
Save