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
},
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() {

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

@ -1905,6 +1905,7 @@ class BaseModelSql extends BaseModel {
parents.split('~').map((parent, index) => {
const { cn, rcn } =
this.belongsToRelations.find(({ rtn }) => rtn === parent) || {};
this.belongsToRelations.find(({ rtn }) => rtn === parent) || {};
const parentIds = [
...new Set(childs.map(c => c[cn] || c[this.columnToAlias[cn]]))
];
@ -2162,7 +2163,7 @@ class BaseModelSql extends BaseModel {
),
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.sort = args.sort || args.s;
return obj;

Loading…
Cancel
Save