Browse Source

Merge pull request #7777 from nocodb/nc-fix/upgrader-bug

ix: SQLite - upgrader timeout bug
pull/7764/head
Raju Udava 9 months ago committed by GitHub
parent
commit
adbaf17817
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 10
      packages/nocodb/src/helpers/formulaHelpers.ts
  2. 2
      packages/nocodb/src/models/CalendarViewColumn.ts
  3. 33
      packages/nocodb/src/models/Column.ts
  4. 20
      packages/nocodb/src/models/Filter.ts
  5. 2
      packages/nocodb/src/models/GalleryViewColumn.ts
  6. 4
      packages/nocodb/src/models/GridViewColumn.ts
  7. 8
      packages/nocodb/src/models/Model.ts
  8. 8
      packages/nocodb/src/models/Sort.ts
  9. 10
      packages/nocodb/src/models/View.ts

10
packages/nocodb/src/helpers/formulaHelpers.ts

@ -2,14 +2,18 @@ import jsep from 'jsep';
import { UITypes } from 'nocodb-sdk';
import type FormulaColumn from '../models/FormulaColumn';
import type { Column } from '~/models';
import Noco from '~/Noco';
export async function getFormulasReferredTheColumn({
export async function getFormulasReferredTheColumn(
{
column,
columns,
}: {
column: Column;
columns: Column[];
}): Promise<Column[]> {
},
ncMeta = Noco.ncMeta,
): Promise<Column[]> {
const fn = (pt) => {
if (pt.type === 'CallExpression') {
return pt.arguments.some((arg) => fn(arg));
@ -25,7 +29,7 @@ export async function getFormulasReferredTheColumn({
const columns = await columnsPromise;
if (c.uidt !== UITypes.Formula) return columns;
const formula = await c.getColOptions<FormulaColumn>();
const formula = await c.getColOptions<FormulaColumn>(ncMeta);
if (fn(jsep(formula.formula))) {
columns.push(c);

2
packages/nocodb/src/models/CalendarViewColumn.ts

@ -93,7 +93,7 @@ export default class CalendarViewColumn {
{
const view = await View.get(column.fk_view_id, ncMeta);
await View.clearSingleQueryCache(view.fk_model_id, [view]);
await View.clearSingleQueryCache(view.fk_model_id, [view], ncMeta);
}
return this.get(id, ncMeta).then(async (viewColumn) => {

33
packages/nocodb/src/models/Column.ts

@ -216,7 +216,7 @@ export default class Column<T = any> implements ColumnType {
ncMeta,
);
await View.clearSingleQueryCache(column.fk_model_id);
await View.clearSingleQueryCache(column.fk_model_id, null, ncMeta);
return col;
}
@ -914,7 +914,7 @@ export default class Column<T = any> implements ColumnType {
// on column delete, delete any optimised single query cache
{
await View.clearSingleQueryCache(col.fk_model_id);
await View.clearSingleQueryCache(col.fk_model_id, null, ncMeta);
}
}
@ -1074,11 +1074,16 @@ export default class Column<T = any> implements ColumnType {
column.column_order.view_id
) {
const viewColumn = (
await View.getColumns(column.column_order.view_id)
await View.getColumns(column.column_order.view_id, ncMeta)
).find((col) => col.fk_column_id === column.id);
await View.updateColumn(column.column_order.view_id, viewColumn.id, {
await View.updateColumn(
column.column_order.view_id,
viewColumn.id,
{
order: column.column_order.order,
});
},
ncMeta,
);
}
// set meta
@ -1098,16 +1103,22 @@ export default class Column<T = any> implements ColumnType {
await this.insertColOption(column, colId, ncMeta);
// on column update, delete any optimised single query cache
await View.clearSingleQueryCache(oldCol.fk_model_id);
await View.clearSingleQueryCache(oldCol.fk_model_id, null, ncMeta);
const updatedColumn = await Column.get({ colId });
const updatedColumn = await Column.get({ colId }, ncMeta);
if (!skipFormulaInvalidate) {
// invalidate formula parsed-tree in which current column is used
// whenever a new request comes for that formula, it will be populated again
getFormulasReferredTheColumn({
getFormulasReferredTheColumn(
{
column: updatedColumn,
columns: await Column.list({ fk_model_id: oldCol.fk_model_id }, ncMeta),
})
columns: await Column.list(
{ fk_model_id: oldCol.fk_model_id },
ncMeta,
),
},
ncMeta,
)
.then(async (formulas) => {
for (const formula of formulas) {
await FormulaColumn.update(
@ -1146,7 +1157,7 @@ export default class Column<T = any> implements ColumnType {
const column = await Column.get({ colId }, ncMeta);
await View.clearSingleQueryCache(column.fk_model_id);
await View.clearSingleQueryCache(column.fk_model_id, null, ncMeta);
}
public getValidators(): any {

20
packages/nocodb/src/models/Filter.ts

@ -213,7 +213,7 @@ export default class Filter implements FilterType {
if (filter.fk_view_id) {
const view = await View.get(filter.fk_view_id, ncMeta);
await View.clearSingleQueryCache(view.fk_model_id, [view]);
await View.clearSingleQueryCache(view.fk_model_id, [view], ncMeta);
}
}
@ -251,9 +251,11 @@ export default class Filter implements FilterType {
// if not a view filter then no need to delete
if (filter.fk_view_id) {
const view = await View.get(filter.fk_view_id, ncMeta);
await View.clearSingleQueryCache(view.fk_model_id, [
{ id: filter.fk_view_id },
]);
await View.clearSingleQueryCache(
view.fk_model_id,
[{ id: filter.fk_view_id }],
ncMeta,
);
}
}
@ -281,9 +283,11 @@ export default class Filter implements FilterType {
if (filter.fk_view_id) {
const view = await View.get(filter.fk_view_id, ncMeta);
await View.clearSingleQueryCache(view.fk_model_id, [
{ id: filter.fk_view_id },
]);
await View.clearSingleQueryCache(
view.fk_model_id,
[{ id: filter.fk_view_id }],
ncMeta,
);
}
}
}
@ -437,7 +441,7 @@ export default class Filter implements FilterType {
// on update delete any optimised single query cache
{
const view = await View.get(viewId, ncMeta);
await View.clearSingleQueryCache(view.fk_model_id, [view]);
await View.clearSingleQueryCache(view.fk_model_id, [view], ncMeta);
}
}

2
packages/nocodb/src/models/GalleryViewColumn.ts

@ -81,7 +81,7 @@ export default class GalleryViewColumn {
// on new view column, delete any optimised single query cache
{
const view = await View.get(column.fk_view_id, ncMeta);
await View.clearSingleQueryCache(view.fk_model_id, [view]);
await View.clearSingleQueryCache(view.fk_model_id, [view], ncMeta);
}
return this.get(id, ncMeta).then(async (viewColumn) => {

4
packages/nocodb/src/models/GridViewColumn.ts

@ -114,7 +114,7 @@ export default class GridViewColumn implements GridColumnType {
// on new view column, delete any optimised single query cache
{
const view = await View.get(column.fk_view_id, ncMeta);
await View.clearSingleQueryCache(view.fk_model_id, [view]);
await View.clearSingleQueryCache(view.fk_model_id, [view], ncMeta);
}
return this.get(id, ncMeta).then(async (viewColumn) => {
@ -159,7 +159,7 @@ export default class GridViewColumn implements GridColumnType {
{
const gridCol = await this.get(columnId, ncMeta);
const view = await View.get(gridCol.fk_view_id, ncMeta);
await View.clearSingleQueryCache(view.fk_model_id, [view]);
await View.clearSingleQueryCache(view.fk_model_id, [view], ncMeta);
}
return res;

8
packages/nocodb/src/models/Model.ts

@ -677,7 +677,7 @@ export default class Model implements TableType {
]);
// clear all the cached query under this model
await View.clearSingleQueryCache(tableId);
await View.clearSingleQueryCache(tableId, null, ncMeta);
// clear all the cached query under related models
for (const col of await this.get(tableId).then((t) => t.getColumns())) {
@ -687,7 +687,11 @@ export default class Model implements TableType {
if (colOptions.fk_related_model_id === tableId) continue;
await View.clearSingleQueryCache(colOptions.fk_related_model_id);
await View.clearSingleQueryCache(
colOptions.fk_related_model_id,
null,
ncMeta,
);
}
return res;

8
packages/nocodb/src/models/Sort.ts

@ -37,7 +37,7 @@ export default class Sort {
// on delete, delete any optimised single query cache
{
const view = await View.get(viewId, ncMeta);
await View.clearSingleQueryCache(view.fk_model_id, [view]);
await View.clearSingleQueryCache(view.fk_model_id, [view], ncMeta);
}
}
@ -95,7 +95,7 @@ export default class Sort {
// on insert, delete any optimised single query cache
{
const view = await View.get(row.fk_view_id, ncMeta);
await View.clearSingleQueryCache(view.fk_model_id, [view]);
await View.clearSingleQueryCache(view.fk_model_id, [view], ncMeta);
}
return this.get(row.id, ncMeta).then(async (sort) => {
@ -169,7 +169,7 @@ export default class Sort {
{
const sort = await this.get(sortId, ncMeta);
const view = await View.get(sort.fk_view_id, ncMeta);
await View.clearSingleQueryCache(view.fk_model_id, [view]);
await View.clearSingleQueryCache(view.fk_model_id, [view], ncMeta);
}
return res;
@ -188,7 +188,7 @@ export default class Sort {
// on delete, delete any optimised single query cache
if (sort?.fk_view_id) {
const view = await View.get(sort.fk_view_id, ncMeta);
await View.clearSingleQueryCache(view.fk_model_id, [view]);
await View.clearSingleQueryCache(view.fk_model_id, [view], ncMeta);
}
}

10
packages/nocodb/src/models/View.ts

@ -878,7 +878,7 @@ export default class View implements ViewType {
await NocoCache.update(`${cacheScope}:${colId}`, updateObj);
// on view column update, delete corresponding single query cache
await View.clearSingleQueryCache(view.fk_model_id, [view]);
await View.clearSingleQueryCache(view.fk_model_id, [view], ncMeta);
return res;
}
@ -920,7 +920,7 @@ export default class View implements ViewType {
);
// on view column update, delete any optimised single query cache
await View.clearSingleQueryCache(view.fk_model_id, [view]);
await View.clearSingleQueryCache(view.fk_model_id, [view], ncMeta);
return { ...existingCol, ...colData };
} else {
@ -1137,7 +1137,7 @@ export default class View implements ViewType {
}
// on update, delete any optimised single query cache
await View.clearSingleQueryCache(view.fk_model_id, [view]);
await View.clearSingleQueryCache(view.fk_model_id, [view], ncMeta);
return view;
}
@ -1188,7 +1188,7 @@ export default class View implements ViewType {
]);
// on update, delete any optimised single query cache
await View.clearSingleQueryCache(view.fk_model_id, [view]);
await View.clearSingleQueryCache(view.fk_model_id, [view], ncMeta);
await Model.getNonDefaultViewsCountAndReset(
{ modelId: view.fk_model_id },
@ -1476,6 +1476,8 @@ export default class View implements ViewType {
views?: { id?: string }[],
ncMeta = Noco.ncMeta,
) {
if (!Noco.isEE()) return;
// get all views of the model
let viewsList =
views || (await NocoCache.getList(CacheScope.VIEW, [modelId])).list;

Loading…
Cancel
Save