Browse Source

fix: handle negative offset in pagination

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/805/head
Pranav C 3 years ago
parent
commit
0e4cf7e5c1
  1. 2
      packages/nc-gui/components/project/spreadsheet/components/pagination.vue
  2. 3
      packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSql.ts

2
packages/nc-gui/components/project/spreadsheet/components/pagination.vue

@ -46,7 +46,7 @@ export default {
this.page = v this.page = v
}, },
count(c) { count(c) {
this.$emit('input', Math.min(this.page, Math.ceil(c / this.size))) this.$emit('input', Math.max(1, Math.min(this.page, Math.ceil(c / this.size))))
} }
}, },
mounted() { mounted() {

3
packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSql.ts

@ -1905,6 +1905,7 @@ class BaseModelSql extends BaseModel {
parents.split('~').map((parent, index) => { parents.split('~').map((parent, index) => {
const { cn, rcn } = const { cn, rcn } =
this.belongsToRelations.find(({ rtn }) => rtn === parent) || {}; this.belongsToRelations.find(({ rtn }) => rtn === parent) || {};
this.belongsToRelations.find(({ rtn }) => rtn === parent) || {};
const parentIds = [ const parentIds = [
...new Set(childs.map(c => c[cn] || c[this.columnToAlias[cn]])) ...new Set(childs.map(c => c[cn] || c[this.columnToAlias[cn]]))
]; ];
@ -2162,7 +2163,7 @@ class BaseModelSql extends BaseModel {
), ),
this.config.limitMin this.config.limitMin
); );
obj.offset = args.offset || args.o || 0; obj.offset = Math.max(+(args.offset || args.o) || 0, 0);
obj.fields = args.fields || args.f || '*'; obj.fields = args.fields || args.f || '*';
obj.sort = args.sort || args.s; obj.sort = args.sort || args.s;
return obj; return obj;

Loading…
Cancel
Save